From 26e92309cb4884c66221e3c86ea50bdd42ed6e0b Mon Sep 17 00:00:00 2001 From: monks-dev Date: Sat, 16 Mar 2024 15:49:59 -0400 Subject: [PATCH 1/4] I made the window show maximized when opened. --- src/app/Application.cpp | 3 +++ src/ui/MainWindow.cpp | 3 ++- src/ui/MainWindow.h | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app/Application.cpp b/src/app/Application.cpp index fc948333a..6db4c9378 100644 --- a/src/app/Application.cpp +++ b/src/app/Application.cpp @@ -295,12 +295,15 @@ bool Application::restoreWindows() { if (dir != Settings::appDir()) { if (MainWindow *win = MainWindow::open(dir.path(), false)) { win->currentView()->setPathspec(mPathspec); + return true; } return false; } + + // Save on exit. MainWindow::setSaveWindowSettings(true); diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index 46586b5f5..23f6e951c 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -301,6 +301,7 @@ QList MainWindow::windows() { return mainWins; } + bool MainWindow::restoreWindows() { QList windows; @@ -386,7 +387,7 @@ MainWindow *MainWindow::open(const git::Repository &repo) { // Create the window. MainWindow *window = new MainWindow(repo); - window->show(); + window->showMaximized(); return window; } diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 65d0be713..80eca07fc 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -13,6 +13,7 @@ #include "git/Repository.h" #include + class RepoView; class TabWidget; class ToolBar; @@ -22,7 +23,7 @@ namespace git { class Submodule; } -class MainWindow : public QMainWindow { +class MainWindow : public QMainWindow{ Q_OBJECT public: From 7fa407d900920a370d28a091666c83cd49de97c6 Mon Sep 17 00:00:00 2001 From: monks-dev Date: Sat, 16 Mar 2024 16:40:06 -0400 Subject: [PATCH 2/4] Added a checkbox in the settings "Tools>Options>Window>View>Show Maximized". Added a check for the checkbox when the window opens to show maximized if checked. --- src/app/Application.cpp | 3 --- src/conf/Setting.cpp | 1 + src/conf/Setting.h | 1 + src/dialogs/SettingsDialog.cpp | 6 ++++++ src/ui/MainWindow.cpp | 11 +++++++++-- src/ui/MainWindow.h | 3 +-- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/app/Application.cpp b/src/app/Application.cpp index 6db4c9378..fc948333a 100644 --- a/src/app/Application.cpp +++ b/src/app/Application.cpp @@ -295,15 +295,12 @@ bool Application::restoreWindows() { if (dir != Settings::appDir()) { if (MainWindow *win = MainWindow::open(dir.path(), false)) { win->currentView()->setPathspec(mPathspec); - return true; } return false; } - - // Save on exit. MainWindow::setSaveWindowSettings(true); diff --git a/src/conf/Setting.cpp b/src/conf/Setting.cpp index 4ff5b8713..2d1af02e1 100644 --- a/src/conf/Setting.cpp +++ b/src/conf/Setting.cpp @@ -19,6 +19,7 @@ void Setting::initialize(QMap &keys) { keys[Id::OpenAllReposInTabs] = "window/tabs/repository"; keys[Id::HideMenuBar] = "window/view/menuBarHidden"; keys[Id::ShowAvatars] = "window/view/avatarsVisible"; + keys[Id::ShowMaximized] = "window/view/showMaximized"; keys[Id::AutoCollapseAddedFiles] = "collapse/added"; keys[Id::AutoCollapseDeletedFiles] = "collapse/deleted"; keys[Id::FilemanagerCommand] = "filemanager/command"; diff --git a/src/conf/Setting.h b/src/conf/Setting.h index b3f9f1252..a6ebe9aa5 100644 --- a/src/conf/Setting.h +++ b/src/conf/Setting.h @@ -43,6 +43,7 @@ class Setting : public SettingsTempl { OpenAllReposInTabs, HideMenuBar, ShowAvatars, + ShowMaximized, AutoCollapseAddedFiles, AutoCollapseDeletedFiles, FilemanagerCommand, diff --git a/src/dialogs/SettingsDialog.cpp b/src/dialogs/SettingsDialog.cpp index 81dc303fe..121ada359 100644 --- a/src/dialogs/SettingsDialog.cpp +++ b/src/dialogs/SettingsDialog.cpp @@ -565,6 +565,11 @@ class WindowPanel : public QWidget { connect(showAvatars, &QCheckBox::toggled, [](bool checked) { Settings::instance()->setValue(Setting::Id::ShowAvatars, checked); }); + QCheckBox *showMaximized = new QCheckBox(tr("Show Window Maximized when opened")); + showMaximized->setChecked(settings->value(Setting::Id::ShowMaximized).toBool()); + connect(showMaximized, &QCheckBox::toggled, [](bool checked) { + Settings::instance()->setValue(Setting::Id::ShowMaximized, checked); + }); QString mergeText = settings->promptDescription(Prompt::Kind::Merge); QCheckBox *merge = new QCheckBox(mergeText, this); @@ -619,6 +624,7 @@ class WindowPanel : public QWidget { layout->addRow(QString(), repoTabs); layout->addRow(tr("View:"), hideMenuBar); layout->addRow(QString(), showAvatars); + layout->addRow(QString(), showMaximized); layout->addRow(tr("Prompt:"), merge); layout->addRow(QString(), revert); layout->addRow(QString(), cherryPick); diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index 23f6e951c..ba8dae4d4 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -301,7 +301,6 @@ QList MainWindow::windows() { return mainWins; } - bool MainWindow::restoreWindows() { QList windows; @@ -387,8 +386,16 @@ MainWindow *MainWindow::open(const git::Repository &repo) { // Create the window. MainWindow *window = new MainWindow(repo); - window->showMaximized(); + const bool showMaximized = + Settings::instance()->value(Setting::Id::ShowMaximized).toBool(); + + if(showMaximized) { + window->showMaximized(); + } else { + window->show(); + } + return window; } diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index 80eca07fc..65d0be713 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -13,7 +13,6 @@ #include "git/Repository.h" #include - class RepoView; class TabWidget; class ToolBar; @@ -23,7 +22,7 @@ namespace git { class Submodule; } -class MainWindow : public QMainWindow{ +class MainWindow : public QMainWindow { Q_OBJECT public: From 6e0ae4c3396ad0f513ccb4ef4f760777e861c68f Mon Sep 17 00:00:00 2001 From: monks-dev Date: Fri, 22 Mar 2024 01:00:38 -0400 Subject: [PATCH 3/4] Clang format --- src/dialogs/SettingsDialog.cpp | 6 ++++-- src/ui/MainWindow.cpp | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/dialogs/SettingsDialog.cpp b/src/dialogs/SettingsDialog.cpp index 121ada359..a246755db 100644 --- a/src/dialogs/SettingsDialog.cpp +++ b/src/dialogs/SettingsDialog.cpp @@ -565,8 +565,10 @@ class WindowPanel : public QWidget { connect(showAvatars, &QCheckBox::toggled, [](bool checked) { Settings::instance()->setValue(Setting::Id::ShowAvatars, checked); }); - QCheckBox *showMaximized = new QCheckBox(tr("Show Window Maximized when opened")); - showMaximized->setChecked(settings->value(Setting::Id::ShowMaximized).toBool()); + QCheckBox *showMaximized = + new QCheckBox(tr("Show Window Maximized when opened")); + showMaximized->setChecked( + settings->value(Setting::Id::ShowMaximized).toBool()); connect(showMaximized, &QCheckBox::toggled, [](bool checked) { Settings::instance()->setValue(Setting::Id::ShowMaximized, checked); }); diff --git a/src/ui/MainWindow.cpp b/src/ui/MainWindow.cpp index ba8dae4d4..5b6971a90 100644 --- a/src/ui/MainWindow.cpp +++ b/src/ui/MainWindow.cpp @@ -388,14 +388,14 @@ MainWindow *MainWindow::open(const git::Repository &repo) { MainWindow *window = new MainWindow(repo); const bool showMaximized = - Settings::instance()->value(Setting::Id::ShowMaximized).toBool(); + Settings::instance()->value(Setting::Id::ShowMaximized).toBool(); - if(showMaximized) { + if (showMaximized) { window->showMaximized(); } else { window->show(); } - + return window; } From c59da64ca904266870c18161c09bf3afad45b132 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Sat, 20 Apr 2024 16:04:05 +0200 Subject: [PATCH 4/4] add changelog entry --- docs/changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.md b/docs/changelog.md index 9f08072ca..20f63e19e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -7,6 +7,7 @@ Description * UI(Commit List): Added a right-click menu entry to rename branches. * UI(Main Menu): Added a menu-entry to rename the current branch. * UI(Diff View): Added line wrapping option in Tools - Options - Diff +* Option to open Gittyup maximized at startup #### Changed