Skip to content
Browse files

Added a menubar to the window. Added File>Quit action to menubar

  • Loading branch information...
1 parent f690c5c commit 5cf9df164b88206d31ae5727eb4cb83baf09a4b6 @priomsrb committed
Showing with 34 additions and 15 deletions.
  1. +2 −10 MainWindow.cpp
  2. +0 −1 MainWindow.h
  3. +32 −4 MainWindow.ui
View
12 MainWindow.cpp
@@ -32,9 +32,7 @@ MainWindow::~MainWindow() {
void MainWindow::setupTrayIcon() {
- quitAction = new QAction("Quit", this);
- quitAction->setIcon(QtIconLoader::icon("application-exit"));
- connect(quitAction, SIGNAL(triggered()), this, SLOT(quit()));
+ connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
hideRestoreAction = new QAction("Hide", this);
connect(hideRestoreAction, SIGNAL(triggered()), this, SLOT(doHideRestoreAction()));
@@ -42,7 +40,7 @@ void MainWindow::setupTrayIcon() {
systemTrayMenu = new QMenu(this);
systemTrayMenu->addSeparator();
systemTrayMenu->addAction(hideRestoreAction);
- systemTrayMenu->addAction(quitAction);
+ systemTrayMenu->addAction(ui->actionQuit);
systemTrayIcon = new QSystemTrayIcon(QIcon(":icons/lighttasks.png"), this);
systemTrayIcon->setContextMenu(systemTrayMenu);
@@ -343,12 +341,6 @@ bool MainWindow::event(QEvent *event) {
return true;
}
- // FIXME: Making "Ctrl+Q" as the shortcut for quitAction didn't work so it is kludged here
- case Qt::Key_Q:
- {
- quitAction->trigger();
- }
-
}
}
}
View
1 MainWindow.h
@@ -56,7 +56,6 @@ protected slots:
State state;
QSystemTrayIcon *systemTrayIcon;
QMenu *systemTrayMenu;
- QAction *quitAction;
QAction *hideRestoreAction;
QRect oldGeometry;
bool reallyQuit;
View
36 MainWindow.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>236</width>
- <height>332</height>
+ <width>230</width>
+ <height>326</height>
</rect>
</property>
<property name="windowTitle">
@@ -32,8 +32,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>218</width>
- <height>258</height>
+ <width>212</width>
+ <height>231</height>
</rect>
</property>
<layout class="QVBoxLayout" name="taskListLayout">
@@ -69,6 +69,34 @@
</item>
</layout>
</widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>230</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="menuFile">
+ <property name="title">
+ <string>&amp;File</string>
+ </property>
+ <addaction name="actionQuit"/>
+ </widget>
+ <addaction name="menuFile"/>
+ </widget>
+ <action name="actionQuit">
+ <property name="text">
+ <string>Quit</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+Q</string>
+ </property>
+ <property name="menuRole">
+ <enum>QAction::QuitRole</enum>
+ </property>
+ </action>
</widget>
<tabstops>
<tabstop>mainOperationButton</tabstop>

0 comments on commit 5cf9df1

Please sign in to comment.
Something went wrong with that request. Please try again.