Skip to content

Commit

Permalink
set fixed size for window; add cmd line args back (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsjudka authored Sep 6, 2023
1 parent 1073a1a commit 9cf6706
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/app/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ MainWindow::MainWindow(QRect geometry)
MainWindow *MainWindow::init(QRect geometry)
{
// force to either screen or custom size
this->setGeometry(geometry);
this->setFixedSize(geometry.size());
this->move(geometry.topLeft());

return this;
}
Expand Down
30 changes: 21 additions & 9 deletions src/dash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,30 @@ int main(int argc, char *argv[])
dash.setApplicationName("dash");
dash.installEventFilter(ActionEventFilter::get_instance());

QSettings settings;
QSize size = dash.primaryScreen()->size();
QPoint pos = dash.primaryScreen()->geometry().topLeft();
settings.beginGroup("Window");
bool fixed = settings.contains("size");
if (fixed) {
size = settings.value("size").toSize();
if (settings.contains("pos"))
pos = settings.value("pos").toPoint();
}
bool fullscreen = true;

QSettings settings;
DASH_LOG(info) << "loaded config: " << settings.fileName().toStdString();

QStringList args = dash.arguments();
if (args.size() > 2) {
size = QSize(args.at(1).toInt(), args.at(2).toInt());
if (args.size() > 4)
pos = QPoint(args.at(3).toInt(), args.at(4).toInt());
fullscreen = false;
}
else {
settings.beginGroup("Window");
if (settings.contains("size")) {
size = settings.value("size").toSize();
if (settings.contains("pos"))
pos = settings.value("pos").toPoint();
fullscreen = false;
}
}

QPixmap pixmap(QPixmap(":/splash.png").scaledToHeight(size.height() / 2));
QSplashScreen splash(pixmap);
splash.setMask(pixmap.mask());
Expand All @@ -35,7 +47,7 @@ int main(int argc, char *argv[])
MainWindow window(QRect(pos, size));
window.setWindowIcon(QIcon(":/logo.png"));
window.setWindowFlags(Qt::FramelessWindowHint);
if (!fixed)
if (fullscreen)
window.setWindowState(Qt::WindowFullScreen);

window.show();
Expand Down

0 comments on commit 9cf6706

Please sign in to comment.