Files

102 lines
3.2 KiB
C++
Raw Permalink Normal View History

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/&gt;.
*
*/
2019-08-24 15:56:39 +08:00
#include "src/MainWindow/mainwindow.h"
#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>
//#include "ukuimenuinterface.h"
2019-08-24 15:56:39 +08:00
int main(int argc, char *argv[])
{
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
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());
// 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;
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;
}
int x=QApplication::primaryScreen()->geometry().x();
int y=QApplication::primaryScreen()->geometry().y();
if(position==0)
w.setGeometry(QRect(x,Style::heightavailable-590,376,590));
else if(position==1)
w.setGeometry(QRect(x,panelSize,376,590));
else if(position==2)
w.setGeometry(QRect(panelSize,y,376,590));
else
w.setGeometry(QRect(Style::widthavailable-376,y,376,590));
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();
w.hide();
2020-01-16 09:24:34 +08:00
return app.exec();
2019-08-24 15:56:39 +08:00
}