comparison src/main.cpp @ 272:d18f1a8cb4df

Add alt+enter key shortcut for toggling fullscreen window.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 17 Mar 2023 13:11:47 +0200
parents df3f902588af
children d8a32eb1f0e9
comparison
equal deleted inserted replaced
271:df3f902588af 272:d18f1a8cb4df
173 173
174 // Read configuration settings 174 // Read configuration settings
175 settings.uiPos = tmpst.value("pos", QPoint(100, 100)).toPoint(); 175 settings.uiPos = tmpst.value("pos", QPoint(100, 100)).toPoint();
176 settings.uiSize = tmpst.value("size", QSize(1000, 600)).toSize(); 176 settings.uiSize = tmpst.value("size", QSize(1000, 600)).toSize();
177 settings.uiScale = tmpst.value("scale", 1.0f).toDouble(); 177 settings.uiScale = tmpst.value("scale", 1.0f).toDouble();
178 settings.uiFullScreen = tmpst.value("fullscreen", false).toBool();
178 settings.dbBackupMode = tmpst.value("dbBackupMode", BACKUP_NONE).toInt(); 179 settings.dbBackupMode = tmpst.value("dbBackupMode", BACKUP_NONE).toInt();
179 settings.dbBackupURL = tmpst.value("dbBackupURL", QString()).toString(); 180 settings.dbBackupURL = tmpst.value("dbBackupURL", QString()).toString();
180 settings.dbBackupSecret = tmpst.value("dbBackupSecret", QString()).toString(); 181 settings.dbBackupSecret = tmpst.value("dbBackupSecret", QString()).toString();
181 settings.dbLastBackup = tmpst.value("dbLastBackup", QDateTime::fromSecsSinceEpoch(0)).toDateTime(); 182 settings.dbLastBackup = tmpst.value("dbLastBackup", QDateTime::fromSecsSinceEpoch(0)).toDateTime();
182 183
195 if (argc >= 2 && strcmp(argv[1], "reset") == 0) 196 if (argc >= 2 && strcmp(argv[1], "reset") == 0)
196 { 197 {
197 settings.uiPos = QPoint(100, 100); 198 settings.uiPos = QPoint(100, 100);
198 settings.uiSize = QSize(1000, 600); 199 settings.uiSize = QSize(1000, 600);
199 settings.uiScale = 1.0f; 200 settings.uiScale = 1.0f;
201 settings.uiFullScreen = false;
200 } 202 }
201 203
202 // 204 //
203 // Create logfile and data directory if they do not already exist 205 // Create logfile and data directory if they do not already exist
204 // 206 //
270 ui->button_LogoImage->setPixmap(logoImage); 272 ui->button_LogoImage->setPixmap(logoImage);
271 ui->button_LogoImage->setAlignment(Qt::AlignCenter); 273 ui->button_LogoImage->setAlignment(Qt::AlignCenter);
272 274
273 slSetCommonStyleSheet(this); 275 slSetCommonStyleSheet(this);
274 276
277 if (settings.uiFullScreen)
278 showFullScreen();
279
275 // Validator for amount input 280 // Validator for amount input
276 QRegExp vregex("\\d{0,4}[,.]\\d{0,2}|\\d{0,4}"); 281 QRegExp vregex("\\d{0,4}[,.]\\d{0,2}|\\d{0,4}");
277 ui->edit_Amount->setValidator(new QRegExpValidator(vregex, this)); 282 ui->edit_Amount->setValidator(new QRegExpValidator(vregex, this));
278 283
279 // Setup person list filtering and sorting 284 // Setup person list filtering and sorting
328 new QShortcut(QKeySequence(QKeySequence::ZoomOut), this, SLOT(changeUIZoomOut())); 333 new QShortcut(QKeySequence(QKeySequence::ZoomOut), this, SLOT(changeUIZoomOut()));
329 new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_0), this, SLOT(changeUIZoomReset())); 334 new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_0), this, SLOT(changeUIZoomReset()));
330 new QShortcut(QKeySequence(Qt::CTRL + Qt::KeypadModifier + Qt::Key_Plus), this, SLOT(changeUIZoomIn())); 335 new QShortcut(QKeySequence(Qt::CTRL + Qt::KeypadModifier + Qt::Key_Plus), this, SLOT(changeUIZoomIn()));
331 new QShortcut(QKeySequence(Qt::CTRL + Qt::KeypadModifier + Qt::Key_Minus), this, SLOT(changeUIZoomOut())); 336 new QShortcut(QKeySequence(Qt::CTRL + Qt::KeypadModifier + Qt::Key_Minus), this, SLOT(changeUIZoomOut()));
332 new QShortcut(QKeySequence(Qt::CTRL + Qt::KeypadModifier + Qt::Key_0), this, SLOT(changeUIZoomReset())); 337 new QShortcut(QKeySequence(Qt::CTRL + Qt::KeypadModifier + Qt::Key_0), this, SLOT(changeUIZoomReset()));
338
339 new QShortcut(QKeySequence(Qt::ALT + Qt::Key_Return), this, SLOT(toggleFullScreen()));
333 340
334 new QShortcut(QKeySequence(Qt::Key_PageUp), this, SLOT(selectRowPrev())); 341 new QShortcut(QKeySequence(Qt::Key_PageUp), this, SLOT(selectRowPrev()));
335 new QShortcut(QKeySequence(Qt::Key_PageDown), this, SLOT(selectRowNext())); 342 new QShortcut(QKeySequence(Qt::Key_PageDown), this, SLOT(selectRowNext()));
336 343
337 new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return), this, SLOT(focusDebtEdit())); 344 new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Return), this, SLOT(focusDebtEdit()));
363 // 370 //
364 SyntilistaMainWindow::~SyntilistaMainWindow() 371 SyntilistaMainWindow::~SyntilistaMainWindow()
365 { 372 {
366 QSettings tmpst(APP_VENDOR, APP_ID); 373 QSettings tmpst(APP_VENDOR, APP_ID);
367 374
368 // Save window size and position 375 // Save settings
369 tmpst.setValue("pos", pos()); 376 tmpst.setValue("pos", pos());
370 tmpst.setValue("size", size()); 377 tmpst.setValue("size", size());
371 378 tmpst.setValue("fullscreen", settings.uiFullScreen);
372 // Other settings
373 tmpst.setValue("scale", settings.uiScale); 379 tmpst.setValue("scale", settings.uiScale);
374 tmpst.setValue("dbBackupMode", settings.dbBackupMode); 380 tmpst.setValue("dbBackupMode", settings.dbBackupMode);
375 tmpst.setValue("dbBackupURL", settings.dbBackupURL); 381 tmpst.setValue("dbBackupURL", settings.dbBackupURL);
376 tmpst.setValue("dbBackupSecret", settings.dbBackupSecret); 382 tmpst.setValue("dbBackupSecret", settings.dbBackupSecret);
377 383
384 QSqlDatabase::database().commit(); 390 QSqlDatabase::database().commit();
385 QSqlDatabase::database().close(); 391 QSqlDatabase::database().close();
386 392
387 // Back up the database 393 // Back up the database
388 if (settings.dbBackupMode != BACKUP_NONE) 394 if (settings.dbBackupMode != BACKUP_NONE)
395 {
389 backupDatabase(); 396 backupDatabase();
397 }
390 else 398 else
391 { 399 {
392 slLog("INFO", 400 slLog("INFO",
393 QStringLiteral("Database backup mode is NONE, not performing backup.")); 401 QStringLiteral("Database backup mode is NONE, not performing backup."));
394 } 402 }
599 void SyntilistaMainWindow::statusMsg(const QString &msg) 607 void SyntilistaMainWindow::statusMsg(const QString &msg)
600 { 608 {
601 slLog("STATUS", msg); 609 slLog("STATUS", msg);
602 ui->statusbar->showMessage(msg); 610 ui->statusbar->showMessage(msg);
603 } 611 }
612
613
614 //
615 //
616 //
617 void SyntilistaMainWindow::toggleFullScreen()
618 {
619 settings.uiFullScreen = !settings.uiFullScreen;
620
621 if (settings.uiFullScreen)
622 {
623 showFullScreen();
624 }
625 else
626 {
627 showMaximized();
628 }
629 }
630
604 631
605 632
606 // 633 //
607 // Window scale / zoom changing 634 // Window scale / zoom changing
608 // 635 //