|
|
@@ -26,26 +26,35 @@
|
|
|
|
|
|
#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 grey; spacing: 0; } "
|
|
|
+ "QToolBar QToolButton { background: white; border: none; border-bottom: 1px solid grey; margin: 0; padding: 0; } "
|
|
|
+ "QToolBar QToolButton:checked { background: %1; color: %2; }";
|
|
|
+}
|
|
|
|
|
|
namespace Mirall {
|
|
|
|
|
|
-QIcon createDummy() {
|
|
|
- QIcon icon;
|
|
|
- QPixmap p(32,32);
|
|
|
- p.fill(Qt::transparent);
|
|
|
- icon.addPixmap(p);
|
|
|
- return icon;
|
|
|
-}
|
|
|
-
|
|
|
SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) :
|
|
|
QDialog(parent),
|
|
|
_ui(new Ui::SettingsDialog)
|
|
|
{
|
|
|
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());
|
|
|
+ toolBar->setStyleSheet(QString::fromAscii(TOOLBAR_CSS).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);
|
|
|
@@ -55,32 +64,45 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) :
|
|
|
|
|
|
setObjectName("Settings"); // required as group for saveGeometry call
|
|
|
|
|
|
- setWindowTitle(tr("%1").arg(Theme::instance()->appNameGUI()));
|
|
|
+ setWindowTitle(Theme::instance()->appNameGUI());
|
|
|
|
|
|
- _accountSettings = new AccountSettings(this);
|
|
|
- addAccount(tr("Account"), _accountSettings);
|
|
|
+ QIcon accountIcon(QLatin1String(":/mirall/resources/accounts.png"));
|
|
|
+ QAction *accountAction = toolBar->addAction(accountIcon, tr("Account"));
|
|
|
+ accountAction->setCheckable(true);
|
|
|
+ _accountSettings = new AccountSettings;
|
|
|
+ _ui->stack->addWidget(_accountSettings);
|
|
|
|
|
|
QIcon protocolIcon(QLatin1String(":/mirall/resources/activity.png"));
|
|
|
- QListWidgetItem *protocol= new QListWidgetItem(protocolIcon, tr("Activity"), _ui->labelWidget);
|
|
|
- protocol->setSizeHint(QSize(0, 32));
|
|
|
- _ui->labelWidget->addItem(protocol);
|
|
|
- _protocolWidget = new ProtocolWidget;
|
|
|
- _protocolIdx = _ui->stack->addWidget(_protocolWidget);
|
|
|
+ _protocolAction = toolBar->addAction(protocolIcon, tr("Activity"));
|
|
|
+ _protocolAction->setCheckable(true);
|
|
|
+ ProtocolWidget *protocolWidget = new ProtocolWidget;
|
|
|
+ _ui->stack->addWidget(protocolWidget);
|
|
|
|
|
|
QIcon generalIcon(QLatin1String(":/mirall/resources/settings.png"));
|
|
|
- QListWidgetItem *general = new QListWidgetItem(generalIcon, tr("General"), _ui->labelWidget);
|
|
|
- general->setSizeHint(QSize(0, 32));
|
|
|
- _ui->labelWidget->addItem(general);
|
|
|
+ QAction *generalAction = toolBar->addAction(generalIcon, tr("General"));
|
|
|
+ generalAction->setCheckable(true);
|
|
|
GeneralSettings *generalSettings = new GeneralSettings;
|
|
|
_ui->stack->addWidget(generalSettings);
|
|
|
|
|
|
QIcon networkIcon(QLatin1String(":/mirall/resources/network.png"));
|
|
|
- QListWidgetItem *network = new QListWidgetItem(networkIcon, tr("Network"), _ui->labelWidget);
|
|
|
- network->setSizeHint(QSize(0, 32));
|
|
|
- _ui->labelWidget->addItem(network);
|
|
|
+ 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(accountIconChanged(QIcon)), SLOT(slotUpdateAccountIcon(QIcon)));
|
|
|
connect( _accountSettings, SIGNAL(openFolderAlias(const QString&)),
|
|
|
@@ -89,10 +111,9 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) :
|
|
|
connect( ProgressDispatcher::instance(), SIGNAL(progressInfo(QString, Progress::Info)),
|
|
|
_accountSettings, SLOT(slotSetProgress(QString, Progress::Info)) );
|
|
|
|
|
|
- _ui->labelWidget->setCurrentRow(_ui->labelWidget->row(_accountItem));
|
|
|
|
|
|
- connect(_ui->labelWidget, SIGNAL(currentRowChanged(int)),
|
|
|
- _ui->stack, SLOT(setCurrentIndex(int)));
|
|
|
+ // default to Account
|
|
|
+ accountAction->setChecked(true);
|
|
|
|
|
|
QPushButton *closeButton = _ui->buttonBox->button(QDialogButtonBox::Close);
|
|
|
connect(closeButton, SIGNAL(clicked()), SLOT(accept()));
|
|
|
@@ -102,23 +123,6 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent) :
|
|
|
connect(showLogWindow, SIGNAL(triggered()), gui, SLOT(slotToggleLogBrowser()));
|
|
|
addAction(showLogWindow);
|
|
|
|
|
|
- int iconSize = 32;
|
|
|
- QListWidget *listWidget = _ui->labelWidget;
|
|
|
- int spacing = 20;
|
|
|
- // reverse at least ~8 characters
|
|
|
- int effectiveWidth = fontMetrics().averageCharWidth() * 8 + iconSize + spacing;
|
|
|
- // less than ~16 characters, elide otherwise
|
|
|
- int maxWidth = fontMetrics().averageCharWidth() * 16 + iconSize + spacing;
|
|
|
- for (int i = 0; i < listWidget->count(); i++) {
|
|
|
- QListWidgetItem *item = listWidget->item(i);
|
|
|
- QFontMetrics fm(item->font());
|
|
|
- int curWidth = fm.width(item->text()) + iconSize + spacing;
|
|
|
- effectiveWidth = qMax(curWidth, effectiveWidth);
|
|
|
- if (curWidth > maxWidth) item->setToolTip(item->text());
|
|
|
- }
|
|
|
- effectiveWidth = qMin(effectiveWidth, maxWidth);
|
|
|
- listWidget->setFixedWidth(effectiveWidth);
|
|
|
-
|
|
|
MirallConfigFile cfg;
|
|
|
cfg.restoreGeometry(this);
|
|
|
}
|
|
|
@@ -128,20 +132,9 @@ SettingsDialog::~SettingsDialog()
|
|
|
delete _ui;
|
|
|
}
|
|
|
|
|
|
-void SettingsDialog::addAccount(const QString &title, QWidget *widget)
|
|
|
-{
|
|
|
- _accountItem = new QListWidgetItem(title);
|
|
|
- _accountItem->setSizeHint(QSize(0, 32));
|
|
|
- _ui->labelWidget->addItem(_accountItem);
|
|
|
- _ui->stack->addWidget(widget);
|
|
|
- _accountSettings->slotSyncStateChange();
|
|
|
-}
|
|
|
-
|
|
|
void SettingsDialog::setGeneralErrors(const QStringList &errors)
|
|
|
{
|
|
|
- if( _accountSettings ) {
|
|
|
- _accountSettings->setGeneralErrors(errors);
|
|
|
- }
|
|
|
+ _accountSettings->setGeneralErrors(errors);
|
|
|
}
|
|
|
|
|
|
// close event is not being called here
|
|
|
@@ -157,14 +150,14 @@ void SettingsDialog::accept() {
|
|
|
QDialog::accept();
|
|
|
}
|
|
|
|
|
|
-void SettingsDialog::slotUpdateAccountIcon(const QIcon &icon)
|
|
|
+void SettingsDialog::slotSwitchPage(QAction *action)
|
|
|
{
|
|
|
- _accountItem->setIcon(icon);
|
|
|
+ _ui->stack->setCurrentWidget(_actions.value(action));
|
|
|
}
|
|
|
|
|
|
void SettingsDialog::showActivityPage()
|
|
|
{
|
|
|
- _ui->labelWidget->setCurrentRow(_protocolIdx);
|
|
|
+ slotSwitchPage(_protocolAction);
|
|
|
}
|
|
|
|
|
|
|