Commit 7180259a authored by JanKusanagi's avatar JanKusanagi

Handle old systray options via GlobalObject

parent 867bf316
......@@ -87,7 +87,7 @@ ConfigDialog::ConfigDialog(GlobalObject *globalObject,
this->createNotificationsPage(&settings);
// Page 9, systray options
this->createSystrayPage(&settings);
this->createSystrayPage();
settings.endGroup();
......@@ -710,15 +710,14 @@ void ConfigDialog::createNotificationsPage(QSettings *settings)
* Page 9, systray options
*
*/
void ConfigDialog::createSystrayPage(QSettings *settings)
void ConfigDialog::createSystrayPage()
{
m_systrayIconTypeCombobox = new QComboBox(this);
m_systrayIconTypeCombobox->addItem(tr("Default"));
m_systrayIconTypeCombobox->addItem(tr("System iconset, if available"));
m_systrayIconTypeCombobox->addItem(tr("Show your current avatar"));
m_systrayIconTypeCombobox->addItem(tr("Custom icon"));
m_systrayIconTypeCombobox->setCurrentIndex(settings->value("systrayIconType",
0).toInt());
m_systrayIconTypeCombobox->setCurrentIndex(m_globalObject->getTrayIconType());
// connect kept old-style
connect(m_systrayIconTypeCombobox, SIGNAL(currentIndexChanged(int)),
this, SLOT(toggleCustomIconButton(int)));
......@@ -726,7 +725,7 @@ void ConfigDialog::createSystrayPage(QSettings *settings)
m_systrayCustomIconButton = new QPushButton(tr("S&elect..."), this);
m_systrayIconLastDir = QDir::homePath();
m_systrayCustomIconFN = settings->value("systrayCustomIconFN").toString();
m_systrayCustomIconFN = m_globalObject->getTrayIconFilename();
// FIXME: merge this with code used in pickCustomIconFile()
// and turn the warning messageBox into a label
if (!QPixmap(m_systrayCustomIconFN).isNull())
......@@ -747,7 +746,7 @@ void ConfigDialog::createSystrayPage(QSettings *settings)
m_systrayHideCheckbox = new QCheckBox(this);
m_systrayHideCheckbox->setChecked(m_globalObject->getHideInTray());
m_systrayHideCheckbox->setChecked(m_globalObject->getTrayHideOnStartup());
m_systrayOptionsLayout = new QFormLayout();
......@@ -1004,8 +1003,9 @@ void ConfigDialog::saveConfiguration()
settings.setValue("systrayIconType", m_systrayIconTypeCombobox->currentIndex());
settings.setValue("systrayCustomIconFN", m_systrayCustomIconFN);
settings.setValue("systrayHideInTray", m_systrayHideCheckbox->isChecked());
m_globalObject->syncTrayOptions(m_systrayHideCheckbox->isChecked()); // FIXME: some
// still empty
m_globalObject->syncTrayOptions(m_systrayIconTypeCombobox->currentIndex(),
m_systrayCustomIconFN,
m_systrayHideCheckbox->isChecked());
settings.endGroup();
......
......@@ -74,7 +74,7 @@ public:
void createComposerPage();
void createPrivacyPage();
void createNotificationsPage(QSettings *settings);
void createSystrayPage(QSettings *settings);
void createSystrayPage();
QComboBox *newAvatarComboBox();
......
......@@ -112,8 +112,9 @@ GlobalObject::GlobalObject(QObject *parent) : QObject(parent)
////////////////////////////////////////////////////////////////////// TRAY
this->syncTrayOptions(settings.value("systrayHideInTray", false).toBool());
// TODO: load the other tray options
this->syncTrayOptions(settings.value("systrayIconType", 0).toInt(),
settings.value("systrayCustomIconFN").toString(),
settings.value("systrayHideInTray", false).toBool());
settings.endGroup();
......@@ -439,17 +440,28 @@ bool GlobalObject::getNotifyInTaskbar()
// Tray options
void GlobalObject::syncTrayOptions(bool hideInTray)
void GlobalObject::syncTrayOptions(int trayIconType, QString trayIconFN,
bool trayHideStartup)
{
m_hideInTray = hideInTray;
m_systrayIconType = trayIconType;
m_systrayIconFN = trayIconFN;
m_systrayHideStartup = trayHideStartup;
}
// TODO, some still handled elsewhere
int GlobalObject::getTrayIconType()
{
return m_systrayIconType;
}
QString GlobalObject::getTrayIconFilename()
{
return m_systrayIconFN;
}
bool GlobalObject::getHideInTray()
bool GlobalObject::getTrayHideOnStartup()
{
return m_hideInTray;
return m_systrayHideStartup;
}
///////////////////////////////////////////////////////////////////////////////
......
......@@ -120,8 +120,11 @@ public:
// Tray options
void syncTrayOptions(bool hideInTray);
bool getHideInTray();
void syncTrayOptions(int trayIconType, QString trayIconFN,
bool trayHideStartup);
int getTrayIconType();
QString getTrayIconFilename();
bool getTrayHideOnStartup();
///////////////////////////////////////////////////////////////////////////
......@@ -239,7 +242,9 @@ private:
// Tray options
bool m_hideInTray;
int m_systrayIconType;
QString m_systrayIconFN;
bool m_systrayHideStartup;
//////////////////////////////////////////////////////////////////////////
......
......@@ -1869,12 +1869,12 @@ void MainWindow::updateConfigSettings()
// System tray icon type and custom icon filename, if any
this->trayIconType = settings.value("systrayIconType", 0).toInt();
QString trayIconFilename = settings.value("systrayCustomIconFN").toString();
this->trayCustomPixmap = QPixmap(trayIconFilename).scaled(32, 32);
this->trayIconType = globalObject->getTrayIconType();
this->trayCustomPixmap = QPixmap(globalObject->getTrayIconFilename())
.scaled(32, 32);
if (trayCustomPixmap.isNull()) // Custom icon image is gone or something
{
trayCustomPixmap = QPixmap(":/icon/32x32/dianara.png");
trayCustomPixmap = QPixmap(QStringLiteral(":/icon/32x32/dianara.png"));
}
this->setTrayIconPixmap(trayCurrentNewCount,
......@@ -3478,7 +3478,7 @@ void MainWindow::toggleMainWindow(bool firstTime)
bool shouldHide = false;
if (firstTime)
{
shouldHide = this->globalObject->getHideInTray();
shouldHide = this->globalObject->getTrayHideOnStartup();
if (shouldHide)
{
qDebug() << "Hiding window on startup due to configuration";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment