Skip to content

Commit

Permalink
Added a checkbox in the settings "Tools>Options>Window>View>Show Maxi…
Browse files Browse the repository at this point in the history
…mized".

Added a check for the checkbox when the window opens to show maximized if checked.
  • Loading branch information
monks-dev committed Mar 16, 2024
1 parent f550e39 commit 643bf33
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
3 changes: 0 additions & 3 deletions src/app/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions src/conf/Setting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void Setting::initialize(QMap<Id, QString> &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";
Expand Down
1 change: 1 addition & 0 deletions src/conf/Setting.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Setting : public SettingsTempl<Setting> {
OpenAllReposInTabs,
HideMenuBar,
ShowAvatars,
ShowMaximized,
AutoCollapseAddedFiles,
AutoCollapseDeletedFiles,
FilemanagerCommand,
Expand Down
6 changes: 6 additions & 0 deletions src/dialogs/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
11 changes: 9 additions & 2 deletions src/ui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ QList<MainWindow *> MainWindow::windows() {
return mainWins;
}


bool MainWindow::restoreWindows() {
QList<MainWindow *> windows;

Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 1 addition & 2 deletions src/ui/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "git/Repository.h"
#include <QMainWindow>


class RepoView;
class TabWidget;
class ToolBar;
Expand All @@ -23,7 +22,7 @@ namespace git {
class Submodule;
}

class MainWindow : public QMainWindow{
class MainWindow : public QMainWindow {
Q_OBJECT

public:
Expand Down

0 comments on commit 643bf33

Please sign in to comment.