forked from blue/squawk
First tray attempt, seems to be working
This commit is contained in:
parent
7192286aeb
commit
7e9eed2075
13 changed files with 201 additions and 7 deletions
|
@ -56,7 +56,7 @@ Squawk::Squawk(Models::Roster& p_rosterModel, QWidget *parent) :
|
|||
connect(m_ui->actionPreferences, &QAction::triggered, this, &Squawk::onPreferences);
|
||||
connect(m_ui->actionAddContact, &QAction::triggered, this, &Squawk::onNewContact);
|
||||
connect(m_ui->actionAddConference, &QAction::triggered, this, &Squawk::onNewConference);
|
||||
connect(m_ui->actionQuit, &QAction::triggered, this, &Squawk::close);
|
||||
connect(m_ui->actionQuit, &QAction::triggered, this, &Squawk::quit);
|
||||
connect(m_ui->comboBox, qOverload<int>(&QComboBox::activated), this, &Squawk::onComboboxActivated);
|
||||
//connect(m_ui->roster, &QTreeView::doubleClicked, this, &Squawk::onRosterItemDoubleClicked);
|
||||
connect(m_ui->roster, &QTreeView::customContextMenuRequested, this, &Squawk::onRosterContextMenu);
|
||||
|
@ -122,6 +122,7 @@ void Squawk::onPreferences()
|
|||
preferences->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(preferences, &Settings::destroyed, this, &Squawk::onPreferencesClosed);
|
||||
connect(preferences, &Settings::changeDownloadsPath, this, &Squawk::changeDownloadsPath);
|
||||
connect(preferences, &Settings::changeTray, this, &Squawk::changeTray);
|
||||
|
||||
preferences->show();
|
||||
} else {
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
|
||||
signals:
|
||||
void closing();
|
||||
void quit();
|
||||
void newAccountRequest(const QMap<QString, QVariant>&);
|
||||
void removeAccountRequest(const QString&);
|
||||
void connectAccount(const QString&);
|
||||
|
@ -74,6 +75,7 @@ signals:
|
|||
void requestVCard(const QString& account, const QString& jid);
|
||||
void uploadVCard(const QString& account, const Shared::VCard& card);
|
||||
void changeDownloadsPath(const QString& path);
|
||||
void changeTray(bool enabled, bool hide);
|
||||
|
||||
void notify(const QString& account, const Shared::Message& msg);
|
||||
void changeSubscription(const Models::Roster::ElId& id, bool subscribe);
|
||||
|
|
|
@ -28,6 +28,23 @@ PageGeneral::PageGeneral(QWidget* parent):
|
|||
|
||||
QSettings settings;
|
||||
m_ui->downloadsPathInput->setText(settings.value("downloadsPath").toString());
|
||||
if (QSystemTrayIcon::isSystemTrayAvailable()) {
|
||||
bool tray = settings.value("tray", false).toBool();
|
||||
m_ui->trayInput->setChecked(tray);
|
||||
if (tray) {
|
||||
m_ui->hideTrayInput->setChecked(settings.value("hideTray", false).toBool());
|
||||
} else {
|
||||
m_ui->hideTrayInput->setEnabled(false);
|
||||
}
|
||||
|
||||
connect(m_ui->trayInput, &QCheckBox::stateChanged, this, &PageGeneral::onTrayChecked);
|
||||
connect(m_ui->hideTrayInput, &QCheckBox::stateChanged, this, &PageGeneral::onHideTrayChecked);
|
||||
} else {
|
||||
m_ui->trayInput->setEnabled(false);
|
||||
m_ui->hideTrayInput->setEnabled(false);
|
||||
m_ui->trayInput->setToolTip(tr("Tray is not available for your system")); //TODO translate
|
||||
}
|
||||
|
||||
connect(m_ui->downloadsPathButton, &QPushButton::clicked, this, &PageGeneral::onBrowseButtonClicked);
|
||||
}
|
||||
|
||||
|
@ -76,3 +93,19 @@ void PageGeneral::onDialogDestroyed()
|
|||
{
|
||||
dialog = nullptr;
|
||||
}
|
||||
|
||||
void PageGeneral::onTrayChecked(int state)
|
||||
{
|
||||
bool enabled = state == Qt::Checked;
|
||||
emit variableModified("tray", enabled);
|
||||
m_ui->hideTrayInput->setEnabled(enabled);
|
||||
if (!enabled) {
|
||||
m_ui->hideTrayInput->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void PageGeneral::onHideTrayChecked(int state)
|
||||
{
|
||||
bool enabled = state == Qt::Checked;
|
||||
emit variableModified("hideTray", enabled);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <QVariant>
|
||||
#include <QSettings>
|
||||
#include <QFileDialog>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
@ -47,6 +48,8 @@ private slots:
|
|||
void onBrowseButtonClicked();
|
||||
void onDialogAccepted();
|
||||
void onDialogDestroyed();
|
||||
void onTrayChecked(int state);
|
||||
void onHideTrayChecked(int state);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::PageGeneral> m_ui;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
<width>477</width>
|
||||
<height>310</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
|
@ -39,6 +39,34 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="trayLabel">
|
||||
<property name="text">
|
||||
<string>Tray icon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QCheckBox" name="trayInput">
|
||||
<property name="text">
|
||||
<string>Mimimize Squawk to tray when closing main window</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="hideTrayLabel">
|
||||
<property name="text">
|
||||
<string>Hide tray icon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="hideTrayInput">
|
||||
<property name="text">
|
||||
<string>Hide tray icon when Squawk main window is visible</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
|
|
@ -57,6 +57,7 @@ void Settings::onVariableModified(const QString& key, const QVariant& value)
|
|||
void Settings::apply()
|
||||
{
|
||||
QSettings settings;
|
||||
bool trayChanged = false;
|
||||
for (const std::pair<const QString, QVariant>& pair: modifiedSettings) {
|
||||
if (pair.first == "style") {
|
||||
Shared::Global::setStyle(pair.second.toString());
|
||||
|
@ -73,8 +74,18 @@ void Settings::apply()
|
|||
emit changeDownloadsPath(path);
|
||||
}
|
||||
}
|
||||
} else if (pair.first == "tray" || pair.first == "hideTray") {
|
||||
bool oldValue = settings.value(pair.first, false).toBool();
|
||||
bool newValue = pair.second.toBool();
|
||||
if (oldValue != newValue) {
|
||||
trayChanged = true;
|
||||
settings.setValue(pair.first, pair.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (trayChanged) {
|
||||
emit changeTray(settings.value("tray", false).toBool(), settings.value("hideTray", false).toBool());
|
||||
}
|
||||
|
||||
modifiedSettings.clear();
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
|
||||
signals:
|
||||
void changeDownloadsPath(const QString& path);
|
||||
void changeTray(bool enable, bool hide);
|
||||
|
||||
public slots:
|
||||
void apply();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue