3 Star 4 Fork 0

优麒麟 / ukui-menu

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.cpp 3.39 KB
一键复制 编辑 原始数据 按行查看 历史
/*
* 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;.
*
*/
#include "src/MainWindow/mainwindow.h"
#include <QtSingleApplication>
#include <QDesktopWidget>
#include <QFile>
#include <QScreen>
#include <QTranslator>
#include <QLocale>
#include <X11/Xlib.h>
#include <syslog.h>
#include "src/UtilityFunction/proxystyle.h"
#include <KWindowEffects>
#include "src/UtilityFunction/utility.h"
int main(int argc, char *argv[])
{
qRegisterMetaType<QVector<QStringList>>("QVector<QStringList>");
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QtSingleApplication app("ukui-menu", argc, argv);
app.setQuitOnLastWindowClosed(false);
if(app.isRunning())
{
app.sendMessage("raise_window_noop");
return EXIT_SUCCESS;
}
// auto Style=new ProxyStyle;
// app.setStyle(Style);
QTranslator translator;
if (translator.load(QLocale(), "ukui-menu", "_", QM_FILES_INSTALL_PATH))
app.installTranslator(&translator);
else
qDebug() << "Load translations file" << QLocale() << "failed!";
MainWindow w;
app.setActivationWindow(&w);
// w.setProperty("useSystemStyleBlur", true);
//测试
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;
}
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();
}
if(position==0)
w.setGeometry(QRect(x+4,y+height-panelSize-Style::minh-3,
Style::minw,Style::minh));
else if(position==1)
w.setGeometry(QRect(x+4,y+panelSize+4,Style::minw,Style::minh));
else if(position==2)
w.setGeometry(QRect(x+panelSize+4,y+4,Style::minw,Style::minh));
else
w.setGeometry(QRect(x+width-panelSize-Style::minw-4,y+4,
Style::minw,Style::minh));
w.show();
w.raise();
w.update();
w.activateWindow();
w.hide();
//测试
return app.exec();
}
C
1
https://gitee.com/ubuntukylin/ukui-menu.git
git@gitee.com:ubuntukylin/ukui-menu.git
ubuntukylin
ukui-menu
ukui-menu
master

搜索帮助