mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 21:02:04 +08:00
Improve Features
Support save current theme setting when exit; Use QScreen::primaryScreen() instead of QDesktopWidget to get desktop size; Ensure only one instance will be running at the same time.
This commit is contained in:
63
src/main.cpp
63
src/main.cpp
@@ -1,19 +1,19 @@
|
||||
#include <DApplication>
|
||||
#include <DWidgetUtil> //Dtk::Widget::moveToCenter(&w); 要调用它,就得引用DWidgetUtil
|
||||
#include <QDesktopWidget>
|
||||
#include <widget.h>
|
||||
#include <QTranslator>
|
||||
#include <DAboutDialog>
|
||||
#include "appitem.h"
|
||||
#include <DApplicationSettings>
|
||||
#include <DWidgetUtil> // Dtk::Widget::moveToCenter(&w); 要调用它,就得引用 DWidgetUtil
|
||||
|
||||
#include <QScreen>
|
||||
|
||||
#include "widget.h"
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
DApplication::loadDXcbPlugin(); //让bar处在标题栏中
|
||||
// DApplication::loadDXcbPlugin(); // 让 bar 处在标题栏中
|
||||
DApplication a(argc, argv);
|
||||
|
||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
a.loadTranslator();//载入翻译
|
||||
a.loadTranslator(); // 载入翻译
|
||||
|
||||
/* Customized DAboutDialog (Can't work on other distro like Ubuntu...)
|
||||
*
|
||||
@@ -21,7 +21,7 @@ int main(int argc, char *argv[])
|
||||
* a.setAboutDialog(&dialog);
|
||||
* dialog.setLicense(QObject::tr("We publish this program under GPL V3"));
|
||||
* dialog.setVersion(DApplication::buildVersion("Version 2.0.2.5"));
|
||||
* dialog.setProductIcon(QIcon::fromTheme("spark-store")); //设置Logo
|
||||
* dialog.setProductIcon(QIcon::fromTheme("spark-store")); // 设置Logo
|
||||
* dialog.setProductName(QLabel::tr("Spark Store"));
|
||||
* dialog.setDescription(
|
||||
* QObject::tr(
|
||||
@@ -52,36 +52,49 @@ int main(int argc, char *argv[])
|
||||
)
|
||||
);
|
||||
|
||||
// 限制单实例运行
|
||||
if(!a.setSingleInstance("spark-store"))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 保存窗口主题设置
|
||||
DApplicationSettings settings;
|
||||
|
||||
Widget w;
|
||||
QDesktopWidget *s=DApplication::desktop();
|
||||
int d_w=s->width();
|
||||
int d_h=s->height();
|
||||
if(d_w<=1366){
|
||||
QScreen *s = DApplication::primaryScreen();
|
||||
int d_w = s->geometry().width();
|
||||
int d_h = s->geometry().height();
|
||||
|
||||
if(d_w <= 1366)
|
||||
{
|
||||
w.setMinimumWidth(925);
|
||||
w.resize(925,650);
|
||||
}else if(d_w<=1920){
|
||||
w.setMinimumWidth(1180);
|
||||
w.resize(1180,760);
|
||||
}else {
|
||||
}
|
||||
else
|
||||
{
|
||||
w.setMinimumWidth(1180);
|
||||
w.resize(1180,760);
|
||||
}
|
||||
if(d_h<=768){
|
||||
|
||||
if(d_h <= 768)
|
||||
{
|
||||
w.setMinimumHeight(650);
|
||||
w.resize(925,650);
|
||||
}else if(d_h<=1080){
|
||||
w.setMinimumHeight(760);
|
||||
w.resize(1180,760);
|
||||
}else {
|
||||
}
|
||||
else
|
||||
{
|
||||
w.setMinimumHeight(760);
|
||||
w.resize(1180,760);
|
||||
}
|
||||
|
||||
QString arg1=argv[1];
|
||||
if(arg1.left(6)=="spk://"){
|
||||
QString arg1 = argv[1];
|
||||
if(arg1.left(6)=="spk://")
|
||||
{
|
||||
w.openUrl(QUrl(argv[1]));
|
||||
}
|
||||
//让打开时界面显示在正中
|
||||
|
||||
// 让打开时界面显示在正中
|
||||
Dtk::Widget::moveToCenter(&w);
|
||||
|
||||
w.show();
|
||||
|
||||
Reference in New Issue
Block a user