Files

116 lines
3.4 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>
2020-07-25 17:22:16 +08:00
#include <X11/Xlib.h>
#include <syslog.h>
2020-11-10 15:00:15 +08:00
#include "src/UtilityFunction/proxystyle.h"
2020-11-18 11:34:24 +08:00
#include <KWindowEffects>
#include "src/UtilityFunction/utility.h"
2020-07-25 17:22:16 +08:00
2019-08-24 15:56:39 +08:00
int main(int argc, char *argv[])
{
2020-05-25 21:49:27 +08:00
qRegisterMetaType<QVector<QStringList>>("QVector<QStringList>");
2020-07-25 17:22:16 +08:00
2020-09-09 17:05:52 +08:00
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
2020-07-25 17:22:16 +08:00
QtSingleApplication app("ukui-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-11-10 15:00:15 +08:00
// auto Style=new ProxyStyle;
// app.setStyle(Style);
2020-01-19 14:18:35 +08:00
QTranslator translator;
2020-07-16 14:44:36 +08:00
if (translator.load(QLocale(), "ukui-menu", "_", QM_FILES_INSTALL_PATH))
app.installTranslator(&translator);
else
qDebug() << "Load translations file" << QLocale() << "failed!";
2020-01-19 14:18:35 +08:00
2019-08-24 15:56:39 +08:00
MainWindow w;
app.setActivationWindow(&w);
2020-11-18 11:34:24 +08:00
// w.setProperty("useSystemStyleBlur", true);
2020-09-29 15:33:03 +08:00
2020-11-10 15:00:15 +08:00
//测试
int position=0;
int panelSize=0;
if(QGSettings::isSchemaInstalled(QString("org.ukui.panel.settings").toLocal8Bit()))
{
QGSettings* gsetting=new QGSettings(QString("org.ukui.panel.settings").toLocal8Bit());
if(gsetting->keys().contains(QString("panelposition")))
position=gsetting->get("panelposition").toInt();
else
position=0;
if(gsetting->keys().contains(QString("panelsize")))
panelSize=gsetting->get("panelsize").toInt();
else
panelSize=46;
}
else
{
position=0;
panelSize=46;
}
2020-01-16 09:24:34 +08:00
int x = getScreenGeometry("x");
int y = getScreenGeometry("y");
int width = getScreenGeometry("width");
int height = getScreenGeometry("height");
if(width==0 || height==0)
{
QRect rect=QApplication::desktop()->screenGeometry(0);
x=rect.x();
y=rect.y();
width=rect.width();
height=rect.height();
}
2020-06-13 10:30:31 +08:00
2020-11-10 15:00:15 +08:00
if(position==0)
w.setGeometry(QRect(x+4,y+height-panelSize-Style::minh-3,
2020-11-10 15:00:15 +08:00
Style::minw,Style::minh));
else if(position==1)
2020-12-18 16:21:37 +08:00
w.setGeometry(QRect(x+4,y+panelSize+4,Style::minw,Style::minh));
2020-11-10 15:00:15 +08:00
else if(position==2)
2020-12-18 16:21:37 +08:00
w.setGeometry(QRect(x+panelSize+4,y+4,Style::minw,Style::minh));
2020-11-10 15:00:15 +08:00
else
w.setGeometry(QRect(x+width-panelSize-Style::minw-4,y+4,
2020-11-10 15:00:15 +08:00
Style::minw,Style::minh));
w.show();
w.raise();
w.update();
w.activateWindow();
w.hide();
//测试
2020-01-16 09:24:34 +08:00
return app.exec();
2019-08-24 15:56:39 +08:00
}