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/>.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2022-01-17 10:26:57 +08:00
|
|
|
#include "mainwindow.h"
|
|
|
|
|
#include "tabletwindow.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-07-25 17:22:16 +08:00
|
|
|
#include <X11/Xlib.h>
|
2020-07-30 14:41:16 +08:00
|
|
|
#include <syslog.h>
|
2022-01-17 10:26:57 +08:00
|
|
|
#include "utility.h"
|
|
|
|
|
#include "file-utils.h"
|
2021-09-23 17:09:32 +08:00
|
|
|
#include <ukuisdk/kylin-com4c.h>
|
|
|
|
|
#include <ukuisdk/kylin-com4cxx.h>
|
|
|
|
|
#define UKUI_SERVICE "org.gnome.SessionManager"
|
|
|
|
|
#define UKUI_PATH "/org/gnome/SessionManager"
|
|
|
|
|
#define UKUI_INTERFACE "org.gnome.SessionManager"
|
2020-07-25 17:22:16 +08:00
|
|
|
|
2021-06-26 16:05:37 +08:00
|
|
|
#include <ukui-log4qt.h>
|
|
|
|
|
|
2019-08-24 15:56:39 +08:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
2021-11-19 09:14:55 +08:00
|
|
|
initUkuiLog4qt("ukui-menu");
|
2022-03-07 09:33:18 +08:00
|
|
|
g_projectCodeName = KDKGetPrjCodeName().c_str();
|
2022-05-10 15:18:24 +08:00
|
|
|
g_subProjectCodeName = KDKGetOSRelease("SUB_PROJECT_CODENAME").c_str();
|
2020-05-25 21:49:27 +08:00
|
|
|
qRegisterMetaType<QVector<QStringList>>("QVector<QStringList>");
|
2021-04-22 10:07:14 +08:00
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0))
|
2021-11-05 16:04:57 +08:00
|
|
|
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
|
|
|
|
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
2021-04-22 10:07:14 +08:00
|
|
|
#endif
|
|
|
|
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
|
|
|
|
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
|
|
|
|
#endif
|
2020-07-11 06:41:57 +00: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
|
|
|
|
2021-11-05 16:04:57 +08:00
|
|
|
if (app.isRunning()) {
|
2019-09-12 17:31:35 +08:00
|
|
|
app.sendMessage("raise_window_noop");
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
}
|
2019-08-24 15:56:39 +08:00
|
|
|
|
2020-01-19 14:18:35 +08:00
|
|
|
QTranslator translator;
|
|
|
|
|
|
2021-11-05 16:04:57 +08:00
|
|
|
if (translator.load(QLocale(), "ukui-menu", "_", QM_FILES_INSTALL_PATH)) {
|
|
|
|
|
app.installTranslator(&translator);
|
|
|
|
|
} else {
|
|
|
|
|
myDebug() << "Load translations file" << QLocale() << "failed!";
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-11 13:47:02 +08:00
|
|
|
if (!g_projectCodeName.contains("V10SP1-edu")) {
|
2022-01-19 14:49:52 +08:00
|
|
|
FileUtils::loadHanziTable(":/src/BackProcess/Search/pinyinWithoutTone.txt");
|
2021-09-23 17:09:32 +08:00
|
|
|
MainWindow w;
|
|
|
|
|
app.setActivationWindow(&w);
|
2020-11-18 11:34:24 +08:00
|
|
|
|
2021-12-16 15:29:04 +08:00
|
|
|
if (Style::m_panelPosition == 0) {
|
|
|
|
|
w.setGeometry(QRect(Style::m_primaryScreenX + 4, Style::m_primaryScreenY + Style::m_availableScreenHeight - Style::minh - 3,
|
2021-11-05 16:04:57 +08:00
|
|
|
Style::minw, Style::minh));
|
2021-12-16 15:29:04 +08:00
|
|
|
} else if (Style::m_panelPosition == 1) {
|
|
|
|
|
w.setGeometry(QRect(Style::m_primaryScreenX + 4, Style::m_primaryScreenY + 4, Style::minw, Style::minh));
|
|
|
|
|
} else if (Style::m_panelPosition == 2) {
|
|
|
|
|
w.setGeometry(QRect(Style::m_primaryScreenX + 4, Style::m_primaryScreenY + 4, Style::minw, Style::minh));
|
2021-11-05 16:04:57 +08:00
|
|
|
} else {
|
2021-12-16 15:29:04 +08:00
|
|
|
w.setGeometry(QRect(Style::m_primaryScreenX + Style::m_availableScreenWidth - Style::minw - 4, Style::m_primaryScreenY + 4,
|
2021-11-05 16:04:57 +08:00
|
|
|
Style::minw, Style::minh));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-23 17:09:32 +08:00
|
|
|
w.show();
|
|
|
|
|
w.raise();
|
|
|
|
|
w.update();
|
|
|
|
|
w.activateWindow();
|
|
|
|
|
w.hide();
|
|
|
|
|
return app.exec();
|
2021-11-05 16:04:57 +08:00
|
|
|
} else {
|
2021-09-23 17:09:32 +08:00
|
|
|
TabletWindow w;
|
2021-11-05 16:04:57 +08:00
|
|
|
app.setActivationWindow(&w);
|
2021-09-23 17:09:32 +08:00
|
|
|
centerToScreen(&w);
|
2021-11-05 16:04:57 +08:00
|
|
|
w.setAttribute(Qt::WA_TranslucentBackground, true);
|
|
|
|
|
w.setAttribute(Qt::WA_X11NetWmWindowTypeDesktop, false);
|
2021-11-18 20:56:06 +08:00
|
|
|
w.setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
|
2021-09-23 17:09:32 +08:00
|
|
|
w.raise();
|
|
|
|
|
w.activateWindow();
|
|
|
|
|
//拉起后通知session
|
|
|
|
|
QDBusInterface interface(UKUI_SERVICE,
|
2021-11-05 16:04:57 +08:00
|
|
|
UKUI_PATH,
|
|
|
|
|
UKUI_INTERFACE,
|
|
|
|
|
QDBusConnection::sessionBus());
|
|
|
|
|
interface.call("startupfinished", "ukui-menu", "finish");
|
2021-09-23 17:09:32 +08:00
|
|
|
return app.exec();
|
|
|
|
|
}
|
2019-08-24 15:56:39 +08:00
|
|
|
}
|
2021-09-23 17:09:32 +08:00
|
|
|
|