Commit b25af97d authored by Edric Milaret's avatar Edric Milaret

settings: add option to stay minimized instead of close

Refs #75805

Change-Id: Idfad314822da68382c18b1b6a2adeb538ef64a25
parent bd29e563
......@@ -78,7 +78,8 @@ HEADERS += mainwindow.h \
videooverlay.h \
imdelegate.h \
contactpicker.h \
contactmethodpicker.h
contactmethodpicker.h \
settingskey.h
FORMS += mainwindow.ui \
callwidget.ui \
......
......@@ -323,7 +323,6 @@ AccountDetails::on_tabWidget_currentChanged(int index)
}
}
void
AccountDetails::onCertButtonClicked()
{
......
......@@ -28,6 +28,9 @@
#include "video/previewmanager.h"
#include "accountserializationadapter.h"
#include "accountstatedelegate.h"
#include "settingskey.h"
#include "accountmodel.h"
#include "protocolmodel.h"
......@@ -66,7 +69,10 @@ ConfigurationWidget::ConfigurationWidget(QWidget *parent) :
ui->startupBox->setChecked(Utils::CheckStartupLink());
ui->ringtonesBox->setModel(RingtoneModel::instance());
ui->historyDaySettingsSpinBox->setValue(CategorizedHistoryModel::instance()->historyLimit());
ui->historyDaySettingsSpinBox->setValue(
CategorizedHistoryModel::instance()->historyLimit());
ui->closeOrMinCheckBox->setChecked(settings_.value(
SettingsKey::closeOrMinimized).toBool());
}
void ConfigurationWidget::atExit() {
......@@ -213,3 +219,9 @@ ConfigurationWidget::on_historyDaySettingsSpinBox_valueChanged(int limit)
if (CategorizedHistoryModel::instance()->historyLimit() != limit)
CategorizedHistoryModel::instance()->setHistoryLimit(limit);
}
void
ConfigurationWidget::on_closeOrMinCheckBox_toggled(bool checked)
{
settings_.setValue(SettingsKey::closeOrMinimized, checked);
}
......@@ -21,6 +21,7 @@
#include <QWidget>
#include <QItemSelection>
#include <QSettings>
#include "navwidget.h"
#include "accountdetails.h"
......@@ -43,7 +44,6 @@ public:
~ConfigurationWidget();
void atExit();
protected:
void showEvent(QShowEvent *event);
......@@ -57,6 +57,7 @@ private slots:
void on_startupBox_toggled(bool checked);
void on_clearHistoryButton_clicked();
void on_historyDaySettingsSpinBox_valueChanged(int limit);
void on_closeOrMinCheckBox_toggled(bool checked);
private slots:
void accountSelected(QItemSelection itemSel);
......@@ -70,6 +71,7 @@ private:
bool isLoading_;
AccountDetails* accountDetails_;
AccountStateDelegate *accountStateDelegate_;
QSettings settings_;
};
#endif // CONFIGURATIONWIDGET_H
......@@ -36,6 +36,9 @@
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>10</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="font">
......@@ -143,6 +146,26 @@
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Misc. Settings</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="closeOrMinCheckBox">
<property name="text">
<string>Keep minimized on close</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
......
/***************************************************************************
* Copyright (C) 2015 by Savoir-Faire Linux *
* Copyright (C) 2015 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
......@@ -92,6 +92,10 @@ main(int argc, char *argv[])
file.close();
}
QCoreApplication::setOrganizationName("Savoir-faire Linux");
QCoreApplication::setOrganizationDomain("ring.cx");
QCoreApplication::setApplicationName("Ring");
MainWindow w;
if (not startMinimized)
......
......@@ -19,6 +19,11 @@
#include "mainbar.h"
#include "ui_mainbar.h"
#include <QSettings>
#include <QMessageBox>
#include "settingskey.h"
#include "callmodel.h"
#include "aboutdialog.h"
......@@ -85,7 +90,22 @@ MainBar::showAboutDialog() {
void
MainBar::on_exitButton_clicked()
{
QCoreApplication::exit();
QSettings settings;
if (not settings.value(SettingsKey::closeOrMinimized).isValid()) {
QMessageBox confirmationDialog;
confirmationDialog.setText("Do you want to keep Ring minimized ?");
confirmationDialog.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
auto ret = confirmationDialog.exec();
if (ret == QMessageBox::Ok)
settings.setValue(SettingsKey::closeOrMinimized, true);
}
if (settings.value(SettingsKey::closeOrMinimized).toBool() == true)
emit minimize();
else
QCoreApplication::exit();
}
void
......
/***************************************************************************
* Copyright (C) 2015 by Savoir-faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#ifndef SETTINGSKEY_H
#define SETTINGSKEY_H
namespace SettingsKey {
constexpr static char closeOrMinimized[] = "closeOrMin";
constexpr static char autoAnswer[] = "autoAnswer";
}
#define accountAutoAnswer(A) (A+SettingsKey::autoAnswer)
#endif // SETTINGSKEY_H
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