Skip to content

Commit

Permalink
Added last part of icons
Browse files Browse the repository at this point in the history
  • Loading branch information
juliagoda committed Oct 5, 2023
1 parent d422088 commit 5f6f3f5
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 37 deletions.
Binary file added resources/icons/menu/pak-gui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions resources/pak-gui.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<file>icons/app/32-apps-pak-gui.png</file>
<file>icons/app/64-apps-pak-gui.png</file>
<file>icons/app/128-apps-pak-gui.png</file>
<file>icons/menu/pak-gui.png</file>
<file>icons/menu/clean.png</file>
<file>icons/menu/download.png</file>
<file>icons/menu/exit.png</file>
Expand Down
66 changes: 51 additions & 15 deletions src/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include "actionsaccesschecker.h"
#include "kstandardaction.h"
#include "kxmlguiwindow.h"
#include "mainwindowview.h"
#include "settingsrecords.h"
#include "src/settings.h"
Expand All @@ -31,21 +32,26 @@
#include <QStatusBar>
#include <QMenu>
#include <QMenuBar>
#include <QDomDocument>

#include <KActionCollection>
#include <KConfigDialog>
#include <KLocalizedString>
#include <KStandardAction>
#include <KNotification>
#include <KHelpMenu>
#include <KXMLGUIFactory>


MainWindow::MainWindow()
: KXmlGuiWindow(),
actions_access_checker{ActionsAccessChecker::actionsAccessChecker(this)},
settings_window{nullptr}
settings_window{nullptr},
help_menu{new KHelpMenu(this, i18n("Other"), false)}
{
// ...
setWindowState(windowState() ^ Qt::WindowMaximized);
setHelpMenuEnabled(false);
setStandardToolBarMenuEnabled(false);
}


Expand All @@ -54,6 +60,7 @@ MainWindow::~MainWindow()
timer_on_logs.stop();
timer_on_updates.stop();

delete close_action;
delete update_action;
delete refresh_action;
delete download_action;
Expand All @@ -63,6 +70,11 @@ MainWindow::~MainWindow()
delete update_mirrors_action;
delete clean_action;
delete sync_polaur_action;
delete switch_language;
delete configure_shortcuts;
delete configure_toolbar;
delete configure_pak;
delete help_menu;

actions_access_checker.reset(nullptr);
Settings::clearRecords();
Expand All @@ -77,8 +89,8 @@ void MainWindow::run()
setCentralWidget(main_window_view);
startSystemTray();
initSignals();
setupGUI(Default, "pak-gui.rc");
setXMLFile("pak-gui.rc");
setupGUI(Save | Create, "pak-gui.rc");
setXMLFile("pak-gui.rc", true);
}


Expand Down Expand Up @@ -109,9 +121,18 @@ void MainWindow::disableOnlineActions()
sync_polaur_action->setDisabled(true);
}

void MainWindow::whatIsThis()

void MainWindow::showAboutApp()
{
KXmlGuiWindow::whatsThis();
Q_ASSERT(help_menu);
help_menu->aboutApplication();
}


void MainWindow::reportBug()
{
Q_ASSERT(help_menu);
help_menu->reportBug();
}


Expand Down Expand Up @@ -234,6 +255,9 @@ void MainWindow::initSignals()
setTimersOnChecks();

KActionCollection* actionCollection = this->actionCollection();
setAction(close_action, MenuAction{i18n("&Close"), QString("exit"), QString("close"), QKeySequence(Qt::CTRL, Qt::Key_Q)});
connect(close_action, &QAction::triggered, main_window_view, &MainWindowView::checkRunningThreadsBeforeQuit);

setAction(update_action, MenuAction{i18n("&Update"), QString("update"), QString("update"), QKeySequence(Qt::CTRL, Qt::Key_U)});
connect(update_action, &QAction::triggered, this, [this]() { if (process->preparedBeforeRun(Process::Task::UpdateInstalledPackages)) process->run(Process::Task::UpdateInstalledPackages); }, Qt::AutoConnection);

Expand Down Expand Up @@ -274,16 +298,28 @@ void MainWindow::initSignals()
setAction(print_statistics_action, MenuAction{i18n("&Statistics"), QString("statistics"), QString("statistics"), QKeySequence(Qt::CTRL, Qt::Key_S, Qt::Key_T)});
connect(print_statistics_action, &QAction::triggered, main_window_view, &MainWindowView::showStatisticsWindow);

disableActions();
setAction(switch_language, MenuAction{i18n("&Configure languages"), QString("configure-languages"), QString("configureLanguage"), QKeySequence(Qt::CTRL, Qt::Key_C, Qt::Key_L)});
connect(switch_language, &QAction::triggered, help_menu, &KHelpMenu::switchApplicationLanguage);

auto quit_action = KStandardAction::quit(main_window_view, SLOT(checkRunningThreadsBeforeQuit()), actionCollection);
quit_action->setIcon(QIcon(":/icons/menu/exit.png"));
auto settings_action = KStandardAction::preferences(this, SLOT(settingsConfigure()), actionCollection);
settings_action->setIcon(QIcon(":/icons/menu/settings.png"));
auto configure_toolbars = KStandardAction::configureToolbars(this, &KXmlGuiWindow::configureToolbars, actionCollection);
configure_toolbars->setIcon(QIcon(":/icons/menu/configure-toolbar.png"));
auto whatsThis = KStandardAction::whatsThis(this, &KXmlGuiWindow::whatsThis, actionCollection);
whatsThis->setIcon(QIcon(":/icons/menu/what-is-this.png"));
setAction(configure_shortcuts, MenuAction{i18n("&Configure shortcuts"), QString("configure-shortcuts"), QString("configureKeyboardShortcuts"), QKeySequence(Qt::CTRL, Qt::Key_S, Qt::Key_H)});
connect(configure_shortcuts, &QAction::triggered, guiFactory(), &KXMLGUIFactory::showConfigureShortcutsDialog);

setAction(configure_toolbar, MenuAction{i18n("&Configure toolbar"), QString("configure-toolbar"), QString("configureToolbars"), QKeySequence(Qt::CTRL, Qt::Key_C, Qt::Key_T)});
connect(configure_toolbar, &QAction::triggered, this, &KXmlGuiWindow::configureToolbars);

setAction(configure_pak, MenuAction{i18n("&Configure pak-gui"), QString("settings"), QString("configurePakGui"), QKeySequence(Qt::CTRL, Qt::Key_P, Qt::Key_G)});
connect(configure_pak, &QAction::triggered, this, &MainWindow::settingsConfigure);

auto handbook = KStandardAction::helpContents(this, &KXmlGuiWindow::appHelpActivated, actionCollection);
handbook->setIcon(QIcon(":/icons/menu/handbook.png"));

auto report_bug = KStandardAction::reportBug(this, &MainWindow::reportBug, actionCollection);
report_bug->setIcon(QIcon(":/icons/menu/report-bug.png"));

auto about_app = KStandardAction::aboutApp(this, &MainWindow::showAboutApp, actionCollection);
about_app->setIcon(QIcon(":/icons/menu/pak-gui.png"));

disableActions();
}


Expand Down
11 changes: 10 additions & 1 deletion src/src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#pragma once

#include <KXmlGuiWindow>
#include <KHelpMenu>

#include <QSharedPointer>
#include <QScopedPointer>
#include <QPointer>
Expand Down Expand Up @@ -63,7 +65,8 @@ private Q_SLOTS:
void enableActions();
void disableActions();
void disableOnlineActions();
void whatIsThis();
void showAboutApp();
void reportBug();

signals:
void closeApp();
Expand All @@ -84,6 +87,7 @@ private Q_SLOTS:
QPointer<Settings> settings_window;
QTimer timer_on_updates;
QTimer timer_on_logs;
QPointer<QAction> close_action;
QPointer<QAction> update_action;
QPointer<QAction> refresh_action;
QPointer<QAction> download_action;
Expand All @@ -93,6 +97,11 @@ private Q_SLOTS:
QPointer<QAction> update_mirrors_action;
QPointer<QAction> clean_action;
QPointer<QAction> sync_polaur_action;
QPointer<QAction> switch_language;
QPointer<QAction> configure_shortcuts;
QPointer<QAction> configure_toolbar;
QPointer<QAction> configure_pak;
QPointer<KHelpMenu> help_menu;
QScopedPointer<SystemTray> system_tray_icon{nullptr};

private:
Expand Down
38 changes: 25 additions & 13 deletions src/src/mainwindowview.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,22 @@
<rect>
<x>0</x>
<y>0</y>
<width>860</width>
<height>632</height>
<width>1366</width>
<height>768</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>1280</width>
<height>720</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
Expand Down Expand Up @@ -109,8 +121,8 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>260</width>
<y>-75</y>
<width>429</width>
<height>766</height>
</rect>
</property>
Expand Down Expand Up @@ -310,7 +322,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>240</width>
<width>409</width>
<height>259</height>
</rect>
</property>
Expand Down Expand Up @@ -469,8 +481,8 @@ padding: 3px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>308</width>
<height>509</height>
<width>442</width>
<height>659</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
Expand Down Expand Up @@ -669,8 +681,8 @@ padding: 3px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>288</width>
<height>173</height>
<width>422</width>
<height>225</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
Expand Down Expand Up @@ -848,8 +860,8 @@ padding: 3px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>274</width>
<height>523</height>
<width>443</width>
<height>659</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
Expand Down Expand Up @@ -1048,8 +1060,8 @@ padding: 3px;</string>
<rect>
<x>0</x>
<y>0</y>
<width>254</width>
<height>180</height>
<width>423</width>
<height>225</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
Expand Down
11 changes: 11 additions & 0 deletions src/src/pak-gui.rc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0
http://www.kde.org/standards/kxmlgui/1.0/kxmlgui.xsd">
<MenuBar>
<Menu name="Program">
<text>P&amp;rogram</text>
<Action name="close"/>
</Menu>
<Menu name="Actions">
<text>A&amp;ctions</text>
<Action name="updateAllPackages"/>
Expand All @@ -21,6 +25,13 @@
<text>P&amp;rint</text>
<Action name="statistics"/>
</Menu>
<Menu name="Settings">
<text>S&amp;ettings</text>
<Action name="configureLanguage"/>
<Action name="configureKeyboardShortcuts"/>
<Action name="configureToolbars"/>
<Action name="configurePakGui"/>
</Menu>
</MenuBar>

<ToolBar name="mainToolBar" noMerge="1">
Expand Down
2 changes: 1 addition & 1 deletion src/src/systemtray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void SystemTray::update(uint packages_count)
{
changeStatusToDefault();

if (main_window->isMinimized() && packages_count > 0)
if ((main_window->isMinimized() || main_window->isHidden()) && packages_count > 0)
{
setStatus(KStatusNotifierItem::NeedsAttention);
setToolTipTitle(i18n("Update"));
Expand Down
3 changes: 1 addition & 2 deletions tests/gui/loggertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ void TestLogger::writeToFileMethodHasCorrectTextFormat()
QString expected_result{QDateTime::currentDateTime().toLocalTime().toString() +
QString("\n\n\n---------------[").append(section_text.toUpper()).append(QString("]---------------")) +
QString("\n\ntext") +
QString("\n\n////////////////////////////////////////////////////////////") +
QString("\n\n\n\n")};
QString("\n\n\n\n\n---------------[END]---------------\n\n")};

QCOMPARE(logger.streamTextResult(), expected_result);
}
Expand Down
30 changes: 30 additions & 0 deletions tests/gui/packagescolumnfixtures.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,16 @@ class MockMainWindow : public MainWindow

}

void setHideAfterCloseFlag()
{
hide_after_close = true;
}

void resetCloseFlag()
{
hide_after_close = false;
}

void run() override
{
initSignals();
Expand All @@ -241,10 +251,30 @@ class MockMainWindow : public MainWindow
print_statistics_action.data()->trigger();
}

void closeEvent(QCloseEvent *event) override
{
if (hide_after_close)
{
event->ignore();
this->hide();
return;
}

if (!main_window_view->isRunningMainThreads())
{
event->accept();
return;
}

event->ignore();
}

friend class TestMainWindow;
friend class MainWindowViewGuiTest;
friend class TestSettingsWindow;
friend class SettingsTest;

bool hide_after_close{false};
};


Expand Down
Loading

0 comments on commit 5f6f3f5

Please sign in to comment.