2020-01-07 20:24:03 +08:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 3, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2019-08-24 15:56:39 +08:00
|
|
|
#include "src/MainWindow/mainwindow.h"
|
2019-09-12 17:31:35 +08:00
|
|
|
#include <QtSingleApplication>
|
2019-08-24 15:56:39 +08:00
|
|
|
#include <QDesktopWidget>
|
|
|
|
|
#include <QFile>
|
2020-01-16 09:24:34 +08:00
|
|
|
#include <QScreen>
|
2020-01-19 14:18:35 +08:00
|
|
|
#include <QTranslator>
|
|
|
|
|
#include <QLocale>
|
2020-02-29 19:49:25 +08:00
|
|
|
//#include "ukuimenuinterface.h"
|
2019-08-24 15:56:39 +08:00
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
2019-09-12 17:31:35 +08:00
|
|
|
QtSingleApplication app("ukui-start-menu",argc,argv);
|
2019-10-28 18:52:43 +08:00
|
|
|
app.setQuitOnLastWindowClosed(false);
|
2019-12-28 17:39:55 +08:00
|
|
|
|
2019-09-12 17:31:35 +08:00
|
|
|
if(app.isRunning())
|
|
|
|
|
{
|
|
|
|
|
app.sendMessage("raise_window_noop");
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
}
|
2019-08-24 15:56:39 +08:00
|
|
|
|
2020-01-07 20:24:03 +08:00
|
|
|
QFile qss(":/data/qss/ukui-menu.qss");
|
2019-08-24 15:56:39 +08:00
|
|
|
qss.open(QFile::ReadOnly);
|
|
|
|
|
qApp->setStyleSheet(qss.readAll());
|
|
|
|
|
|
2020-04-01 11:59:53 +08:00
|
|
|
// QGSettings* setting=new QGSettings(QString("org.mate.interface").toLocal8Bit());
|
|
|
|
|
// QString value=setting->get("font-name").toString();
|
|
|
|
|
// QFont font;
|
|
|
|
|
// font.setFamily(value);
|
|
|
|
|
// qApp->setFont(font);
|
|
|
|
|
|
2020-01-19 14:18:35 +08:00
|
|
|
QString locale = QLocale::system().name();
|
|
|
|
|
QTranslator translator;
|
|
|
|
|
if (locale == "zh_CN"){
|
|
|
|
|
if (translator.load(":/ukui_menu_ch.qm"))
|
|
|
|
|
app.installTranslator(&translator);
|
|
|
|
|
else
|
|
|
|
|
qDebug() << "Load translations file" << locale << "failed!";
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 20:24:03 +08:00
|
|
|
char style[400];
|
2020-03-07 23:57:27 +08:00
|
|
|
sprintf(style,"QToolTip{min-height:30px;border-style: none;border:1px solid rgba(255, 255, 255, 0.2);"
|
|
|
|
|
"padding-left:4px;padding-top:0px;padding-right:4px;padding-bottom:0px;border-radius:3px;"
|
|
|
|
|
"font-size:14px;color:#ffffff;background-color:%s;}",
|
2020-01-07 20:24:03 +08:00
|
|
|
ToolTipBackground);
|
|
|
|
|
qApp->setStyleSheet(style);
|
|
|
|
|
|
2019-08-24 15:56:39 +08:00
|
|
|
MainWindow w;
|
2020-04-07 10:52:53 +08:00
|
|
|
QFileInfo fileInfo(QString("/usr/share/glib-2.0/schemas/org.ukui.panel.settings.gschema.xml"));
|
|
|
|
|
int position=0;
|
|
|
|
|
int panelSize=0;
|
|
|
|
|
if(fileInfo.exists())
|
|
|
|
|
{
|
|
|
|
|
QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit());
|
|
|
|
|
position=gsetting->get("panelposition").toInt();
|
|
|
|
|
panelSize=gsetting->get("panelsize").toInt();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
position=0;
|
|
|
|
|
panelSize=46;
|
|
|
|
|
}
|
2020-04-12 21:41:47 +08:00
|
|
|
|
|
|
|
|
int x=QApplication::primaryScreen()->geometry().x();
|
|
|
|
|
int y=QApplication::primaryScreen()->geometry().y();
|
|
|
|
|
|
2020-02-29 19:49:25 +08:00
|
|
|
if(position==0)
|
2020-04-12 21:41:47 +08:00
|
|
|
w.setGeometry(QRect(x,Style::heightavailable-590,376,590));
|
2020-02-29 19:49:25 +08:00
|
|
|
else if(position==1)
|
2020-04-12 21:41:47 +08:00
|
|
|
w.setGeometry(QRect(x,panelSize,376,590));
|
2020-02-29 19:49:25 +08:00
|
|
|
else if(position==2)
|
2020-04-12 21:41:47 +08:00
|
|
|
w.setGeometry(QRect(panelSize,y,376,590));
|
2020-02-29 19:49:25 +08:00
|
|
|
else
|
2020-04-12 21:41:47 +08:00
|
|
|
w.setGeometry(QRect(Style::widthavailable-376,y,376,590));
|
2020-02-29 19:49:25 +08:00
|
|
|
app.setActivationWindow(&w);
|
2020-01-16 09:24:34 +08:00
|
|
|
|
|
|
|
|
//注释掉,以保证自启动时不显示界面
|
2019-08-24 15:56:39 +08:00
|
|
|
w.show();
|
|
|
|
|
w.raise();
|
|
|
|
|
w.activateWindow();
|
2020-03-10 21:17:12 +08:00
|
|
|
w.hide();
|
2020-01-16 09:24:34 +08:00
|
|
|
|
2019-09-12 17:31:35 +08:00
|
|
|
return app.exec();
|
2019-08-24 15:56:39 +08:00
|
|
|
}
|