forked from owncloud/client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettingsdialog.cpp
More file actions
170 lines (139 loc) · 5.65 KB
/
Copy pathsettingsdialog.cpp
File metadata and controls
170 lines (139 loc) · 5.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
* Copyright (C) by Daniel Molkentin <danimo@owncloud.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; version 2 of the License.
*
* 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.
*/
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
#include "folderman.h"
#include "theme.h"
#include "generalsettings.h"
#include "networksettings.h"
#include "accountsettings.h"
#include "configfile.h"
#include "progressdispatcher.h"
#include "owncloudgui.h"
#include "protocolwidget.h"
#include <QLabel>
#include <QStandardItemModel>
#include <QStackedWidget>
#include <QPushButton>
#include <QDebug>
#include <QSettings>
#include <QToolBar>
#include <QLayout>
namespace {
const char TOOLBAR_CSS[] =
"QToolBar { background: white; margin: 0; padding: 0; border: none; border-bottom: 1px solid %1; spacing: 0; } "
"QToolBar QToolButton { background: white; border: none; border-bottom: 1px solid %1; margin: 0; padding: 0; } "
"QToolBar QToolButton:checked { background: %2; color: %3; }";
}
namespace OCC {
//
// Whenever you change something here check both settingsdialog.cpp and settingsdialogmac.cpp !
//
SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) :
QDialog(parent)
, _ui(new Ui::SettingsDialog)
, _accountSettings(new AccountSettings)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
_ui->setupUi(this);
QToolBar *toolBar = new QToolBar;
toolBar->setIconSize(QSize(32,32));
QString highlightColor(palette().highlight().color().name());
QString altBase(palette().alternateBase().color().name());
QString dark(palette().dark().color().name());
toolBar->setStyleSheet(QString::fromAscii(TOOLBAR_CSS).arg(dark).arg(highlightColor).arg(altBase));
toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
layout()->setMenuBar(toolBar);
// People perceive this as a Window, so also make Ctrl+W work
QAction *closeWindowAction = new QAction(this);
closeWindowAction->setShortcut(QKeySequence("Ctrl+W"));
connect(closeWindowAction, SIGNAL(triggered()), SLOT(accept()));
addAction(closeWindowAction);
setObjectName("Settings"); // required as group for saveGeometry call
setWindowTitle(Theme::instance()->appNameGUI());
QIcon accountIcon(QLatin1String(":/client/resources/account.png"));
QAction *accountAction = toolBar->addAction(accountIcon, tr("Account"));
accountAction->setCheckable(true);
_ui->stack->addWidget(_accountSettings);
QIcon protocolIcon(QLatin1String(":/client/resources/activity.png"));
_protocolAction = toolBar->addAction(protocolIcon, tr("Activity"));
_protocolAction->setCheckable(true);
ProtocolWidget *protocolWidget = new ProtocolWidget;
_ui->stack->addWidget(protocolWidget);
QIcon generalIcon(QLatin1String(":/client/resources/settings.png"));
QAction *generalAction = toolBar->addAction(generalIcon, tr("General"));
generalAction->setCheckable(true);
GeneralSettings *generalSettings = new GeneralSettings;
_ui->stack->addWidget(generalSettings);
QIcon networkIcon(QLatin1String(":/client/resources/network.png"));
QAction *networkAction = toolBar->addAction(networkIcon, tr("Network"));
networkAction->setCheckable(true);
NetworkSettings *networkSettings = new NetworkSettings;
_ui->stack->addWidget(networkSettings);
_actions.insert(accountAction, _accountSettings);
_actions.insert(_protocolAction, protocolWidget);
_actions.insert(generalAction, generalSettings);
_actions.insert(networkAction, networkSettings);
QActionGroup *group = new QActionGroup(this);
group->addAction(accountAction);
group->addAction(_protocolAction);
group->addAction(generalAction);
group->addAction(networkAction);
group->setExclusive(true);
connect(group, SIGNAL(triggered(QAction*)), SLOT(slotSwitchPage(QAction*)));
connect( _accountSettings, SIGNAL(folderChanged()), gui, SLOT(slotFoldersChanged()));
connect( _accountSettings, SIGNAL(openFolderAlias(const QString&)),
gui, SLOT(slotFolderOpenAction(QString)));
connect( ProgressDispatcher::instance(), SIGNAL(progressInfo(QString, Progress::Info)),
_accountSettings, SLOT(slotSetProgress(QString, Progress::Info)) );
// default to Account
accountAction->setChecked(true);
QPushButton *closeButton = _ui->buttonBox->button(QDialogButtonBox::Close);
connect(closeButton, SIGNAL(clicked()), SLOT(accept()));
QAction *showLogWindow = new QAction(this);
showLogWindow->setShortcut(QKeySequence("F12"));
connect(showLogWindow, SIGNAL(triggered()), gui, SLOT(slotToggleLogBrowser()));
addAction(showLogWindow);
ConfigFile cfg;
cfg.restoreGeometry(this);
}
SettingsDialog::~SettingsDialog()
{
delete _ui;
}
void SettingsDialog::setGeneralErrors(const QStringList &errors)
{
_accountSettings->setGeneralErrors(errors);
}
// close event is not being called here
void SettingsDialog::reject() {
ConfigFile cfg;
cfg.saveGeometry(this);
QDialog::reject();
}
void SettingsDialog::accept() {
ConfigFile cfg;
cfg.saveGeometry(this);
QDialog::accept();
}
void SettingsDialog::slotSwitchPage(QAction *action)
{
_ui->stack->setCurrentWidget(_actions.value(action));
}
void SettingsDialog::showActivityPage()
{
if (_protocolAction) {
slotSwitchPage(_protocolAction);
}
}
} // namespace OCC