Skip to content

Commit

Permalink
Ui fixes:
Browse files Browse the repository at this point in the history
click tray icon to toggle
reactive windows
  • Loading branch information
CountMurphy committed Sep 27, 2020
1 parent a4aad0a commit ca76a5e
Show file tree
Hide file tree
Showing 7 changed files with 402 additions and 522 deletions.
136 changes: 66 additions & 70 deletions aboutdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>435</width>
<height>318</height>
<width>376</width>
<height>258</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>About Dialog</string>
</property>
Expand All @@ -20,74 +26,64 @@
<property name="modal">
<bool>true</bool>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>70</x>
<y>280</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLabel" name="lblIcon">
<property name="geometry">
<rect>
<x>20</x>
<y>0</y>
<width>121</width>
<height>121</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QLabel" name="lblInfo">
<property name="geometry">
<rect>
<x>80</x>
<y>0</y>
<width>271</width>
<height>261</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QLabel" name="lbllink">
<property name="geometry">
<rect>
<x>90</x>
<y>160</y>
<width>341</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QLabel" name="lblVersion">
<property name="geometry">
<rect>
<x>20</x>
<y>280</y>
<width>111</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="1" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lblVersion">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="0" column="2" rowspan="2" colspan="2">
<widget class="QLabel" name="lblInfo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="lblIcon">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="lbllink">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="Icons.qrc"/>
Expand Down
4 changes: 4 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ int main(int argc, char *argv[])
QApplication a(argc, argv);
a.setApplicationName("QTalarm");
a.setOrganizationName("QTalarm");
//forcing default font size.
//QFont font = qApp->font();
//font.setPixelSize(10);
//qApp->setFont(font);
MainWindow w;
if(FileIO::LoadWindowShow() || !QSystemTrayIcon::isSystemTrayAvailable())
{
Expand Down
17 changes: 11 additions & 6 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ MainWindow::MainWindow(QWidget *parent) :

//set up ui slots
connect(QAquit,SIGNAL(triggered()),this,SLOT(Quit()));
connect(QAshow,SIGNAL(triggered()),this,SLOT(ShowWindow()));
connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(ShowWindow(QSystemTrayIcon::ActivationReason)));
connect(QAshow,SIGNAL(triggered()),this,SLOT(ToggleWindow()));
connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(ToggleWindow(QSystemTrayIcon::ActivationReason)));
connect(ui->actionQuit,SIGNAL(triggered()),this,SLOT(Quit()));
connect(ui->actionAbout_QT,SIGNAL(triggered()),qApp,SLOT(aboutQt()));
connect(ui->actionAbout_QTalam,SIGNAL(triggered()),this,SLOT(ShowAbout()));
Expand Down Expand Up @@ -123,22 +123,27 @@ void MainWindow::SetupClock()
CurrentTime->start(500);
}

void MainWindow::ShowWindow(QSystemTrayIcon::ActivationReason Reason)
void MainWindow::ToggleWindow(QSystemTrayIcon::ActivationReason Reason)
{
if(Reason==QSystemTrayIcon::DoubleClick || Reason==QSystemTrayIcon::Trigger)
{
ShowWindow();
ToggleWindow();
}
}

void MainWindow::ShowWindow()
void MainWindow::ToggleWindow()
{
if(this->CurAlarm->isPlaying())
{
this->CurAlarm->Stop();
}
ui->TestBtn->setText("Test");
this->show();
if(this->isHidden())
{
this->show();
}else{
this->hide();
}
}

void MainWindow::SetTime()
Expand Down
4 changes: 2 additions & 2 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ class MainWindow : public QMainWindow
void UpdateListWidget();

private slots:
void ShowWindow();
void ToggleWindow();
void ShowActiveAlarm(int index);
void ShowWindow(QSystemTrayIcon::ActivationReason);
void ToggleWindow(QSystemTrayIcon::ActivationReason);
void AddRemoveAlarm(QAbstractButton*);
void SetTime();
void SetCustomDate();
Expand Down
Loading

0 comments on commit ca76a5e

Please sign in to comment.