From 995d63c9799df2a6c54773e099399f1922b62a1f Mon Sep 17 00:00:00 2001 From: defnax Date: Sat, 10 May 2014 18:05:18 +0000 Subject: [PATCH] Added new fixes from Phenom (AddFrameListeInsteadOfToolBar_v0.6_7360.patch) Add an option for List item icon size. Save state for List Item and Option window. Make ListItem linked with Function pointer instead of SLOT char. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7361 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-gui/src/gui/MainWindow.cpp | 44 +- retroshare-gui/src/gui/MainWindow.h | 5 +- retroshare-gui/src/gui/MainWindow.ui | 28 +- .../src/gui/settings/AppearancePage.cpp | 30 ++ .../src/gui/settings/AppearancePage.ui | 502 ++++++++++-------- .../src/gui/settings/rsettingswin.cpp | 52 +- .../src/gui/settings/rsettingswin.h | 5 +- .../src/gui/settings/rsharesettings.cpp | 40 ++ .../src/gui/settings/rsharesettings.h | 5 + retroshare-gui/src/gui/settings/settings.ui | 249 +++++---- 10 files changed, 561 insertions(+), 399 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 651cd069f..6b094a181 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -235,6 +235,11 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) //ui->stackPages->setCurrentIndex(Settings->getLastPageInMainWindow()); setNewPage(Settings->getLastPageInMainWindow()); + /* Load listWidget postion */ + QByteArray geometry = Settings->valueFromGroup("MainWindow", "SplitterState", QByteArray()).toByteArray(); + if (geometry.isEmpty() == false) { + ui->splitter->restoreState(geometry); + } /** StatusBar section ********/ /* initialize combobox in status bar */ @@ -304,6 +309,8 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags) MainWindow::~MainWindow() { Settings->setLastPageInMainWindow(ui->stackPages->currentIndex()); + /* Save listWidget position */ + Settings->setValueToGroup("MainWindow", "SplitterState", ui->splitter->saveState()); delete peerstatus; delete natstatus; @@ -463,15 +470,16 @@ void MainWindow::initStackedPage() #ifdef UNFINISHED - addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui->toolBar), SLOT(showApplWindow())); + addAction(new QAction(QIcon(IMAGE_UNFINISHED), tr("Unfinished"), ui->toolBar), &MainWindow::showApplWindow, SLOT(showApplWindow())); ui->toolBarAction->addSeparator(); notify += applicationWindow->getNotify(); #endif - addAction(new QAction(QIcon(IMAGE_ADDFRIEND), tr("Add"), ui->toolBarAction), SLOT(addFriend())); - addAction(new QAction(QIcon(IMAGE_PREFERENCES), tr("Options"), ui->toolBarAction), SLOT(showSettings())); - addAction(new QAction(QIcon(IMAGE_ABOUT), tr("About"), ui->toolBarAction), SLOT(showabout())); - addAction(new QAction(QIcon(IMAGE_QUIT), tr("Quit"), ui->toolBarAction), SLOT(doQuit())); + /** Add icon on Action bar */ + addAction(new QAction(QIcon(IMAGE_ADDFRIEND), tr("Add"), ui->toolBarAction), &MainWindow::addFriend, SLOT(addFriend())); + addAction(new QAction(QIcon(IMAGE_PREFERENCES), tr("Options"), ui->toolBarAction), &MainWindow::showSettings, SLOT(showSettings())); + addAction(new QAction(QIcon(IMAGE_ABOUT), tr("About"), ui->toolBarAction), &MainWindow::showabout, SLOT(showabout())); + addAction(new QAction(QIcon(IMAGE_QUIT), tr("Quit"), ui->toolBarAction), &MainWindow::doQuit, SLOT(doQuit())); QList > >::iterator notifyIt; for (notifyIt = notify.begin(); notifyIt != notify.end(); ++notifyIt) { @@ -498,19 +506,22 @@ QAction *MainWindow::createPageAction(const QIcon &icon, const QString &text, QA } /** Adds the given action to the toolbar and hooks its triggered() signal to - * the specified slot (if given). */ -void MainWindow::addAction(QAction *action, const char *slot) + * the specified slot (if given). + * Have to pass function pointer and slot, because we can't make slot of function pointer */ +void MainWindow::addAction(QAction *action, FunctionType actionFunction, const char *slot) { QFont font; font = action->font(); font.setPointSize(9); action->setFont(font); ui->toolBarAction->addAction(action); - connect(action, SIGNAL(triggered()), this, slot); + if (slot) connect(action, SIGNAL(triggered()), this, slot); QListWidgetItem *item = new QListWidgetItem(action->icon(),action->text()) ; item->setData(Qt::UserRole,QString(slot)); ui->listWidget->addItem(item) ; + + if (slot) _functionList[slot] = actionFunction; } /** Add the given page to the stackPage and list. */ @@ -540,12 +551,9 @@ void MainWindow::setNewPage(int page) ui->listWidget->setCurrentRow(page); } else { QString procName = ui->listWidget->item(page)->data(Qt::UserRole).toString(); -#ifdef UNFINISHED - if (procName == SLOT(showApplWindow())) showApplWindow(); -#endif - if (procName == SLOT(showSettings())) showSettings(); - if (procName == SLOT(showabout())) showabout(); - if (procName == SLOT(doQuit())) doQuit(); + FunctionType function = _functionList[procName]; + if (function) (this->*function)(); + ui->listWidget->setCurrentRow(ui->stackPages->currentIndex()); } } @@ -1404,11 +1412,13 @@ void MainWindow::settingsChanged() ui->listWidget->item(i)->setHidden(Settings->getActionButtonLoc()); } } - int size = Settings->getToolButtonSize(); + int toolSize = Settings->getToolButtonSize(); ui->toolBarPage->setToolButtonStyle(Settings->getToolButtonStyle()); - ui->toolBarPage->setIconSize(QSize(size,size)); + ui->toolBarPage->setIconSize(QSize(toolSize,toolSize)); ui->toolBarAction->setToolButtonStyle(Settings->getToolButtonStyle()); - ui->toolBarAction->setIconSize(QSize(size,size)); + ui->toolBarAction->setIconSize(QSize(toolSize,toolSize)); + int itemSize = Settings->getListItemIconSize(); + ui->listWidget->setIconSize(QSize(itemSize,itemSize)); } void MainWindow::externalLinkActivated(const QUrl &url) diff --git a/retroshare-gui/src/gui/MainWindow.h b/retroshare-gui/src/gui/MainWindow.h index 86db546fc..dc4bac8c1 100644 --- a/retroshare-gui/src/gui/MainWindow.h +++ b/retroshare-gui/src/gui/MainWindow.h @@ -232,10 +232,13 @@ private: /** A BandwidthGraph object which handles monitoring RetroShare bandwidth usage */ BandwidthGraph* _bandwidthGraph; + typedef void (MainWindow::*FunctionType)(); + /** Creates a new action for a Main page. */ QAction* createPageAction(const QIcon &icon, const QString &text, QActionGroup *group); /** Adds a new action to the toolbar. */ - void addAction(QAction *action, const char *slot = 0); + void addAction(QAction *action, FunctionType actionFunction, const char *slot = 0); + QMap _functionList; QString nameAndLocation; diff --git a/retroshare-gui/src/gui/MainWindow.ui b/retroshare-gui/src/gui/MainWindow.ui index 24393299d..ac1a0a52c 100644 --- a/retroshare-gui/src/gui/MainWindow.ui +++ b/retroshare-gui/src/gui/MainWindow.ui @@ -12,34 +12,20 @@ MainWindow - - - - - 0 - - - 0 - - - 0 - - + + + + 0 - - - 0 - 0 - 571 - 421 - - Qt::Horizontal + + 2 + diff --git a/retroshare-gui/src/gui/settings/AppearancePage.cpp b/retroshare-gui/src/gui/settings/AppearancePage.cpp index 81f6e49fa..63f1d1dc2 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.cpp +++ b/retroshare-gui/src/gui/settings/AppearancePage.cpp @@ -102,6 +102,21 @@ bool AppearancePage::save(QString &errmsg) case 3: Settings->setToolButtonSize(32); } + switch (ui.cmboListItemSize->currentIndex()) + { + case 0: + Settings->setListItemIconSize(8); + break; + case 1: + Settings->setListItemIconSize(16); + break; + case 2: + default: + Settings->setListItemIconSize(24); + break; + case 3: + Settings->setListItemIconSize(32); + } /* Set to new style */ Rshare::setStyle(ui.cmboStyle->currentText()); @@ -159,6 +174,21 @@ void AppearancePage::load() case 32: ui.cmboTollButtonsSize->setCurrentIndex(3); } + switch (Settings->getListItemIconSize()) + { + case 8: + ui.cmboListItemSize->setCurrentIndex(0); + break; + case 16: + ui.cmboListItemSize->setCurrentIndex(1); + break; + case 24: + default: + ui.cmboListItemSize->setCurrentIndex(2); + break; + case 32: + ui.cmboListItemSize->setCurrentIndex(3); + } } void AppearancePage::loadStyleSheet(int index) diff --git a/retroshare-gui/src/gui/settings/AppearancePage.ui b/retroshare-gui/src/gui/settings/AppearancePage.ui index b26b4cc63..5d7b1ab4a 100755 --- a/retroshare-gui/src/gui/settings/AppearancePage.ui +++ b/retroshare-gui/src/gui/settings/AppearancePage.ui @@ -20,190 +20,6 @@ 0 - - - - - 0 - 75 - - - - Qt::NoContextMenu - - - Tool Bar - - - - - - QFrame::StyledPanel - - - QFrame::Plain - - - - 2 - - - - - On Tool Bar - - - - - - - On List Item - - - - - - - Qt::Horizontal - - - - 300 - 16 - - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Plain - - - - 2 - - - - - On Tool Bar - - - - - - - On List Item - - - - - - - Qt::Horizontal - - - - 300 - 16 - - - - - - - - - - - Where do you want to have the buttons for menu? - - - - - - - Where do you want to have the buttons for the page? - - - - - - - Choose the style of Tool Buttons. - - - - - - - - Icon Only - - - - - Text Only - - - - - Text Beside Icon - - - - - Text Under Icon - - - - - - - - - Icon Size = 8x8 - - - - - Icon Size = 16x16 - - - - - Icon Size = 24x24 - - - - - Inon Size = 32x32 - - - - - - - - - - - Qt::Vertical - - - - 361 - 61 - - - - @@ -261,44 +77,6 @@ - - - - - 0 - 64 - - - - Style Sheet - - - - - - - 150 - 0 - - - - - - - - Qt::Horizontal - - - - 215 - 20 - - - - - - - @@ -346,6 +124,286 @@ + + + + + 0 + 64 + + + + Style Sheet + + + + + + + 150 + 0 + + + + + + + + Qt::Horizontal + + + + 215 + 20 + + + + + + + + + + + Qt::Vertical + + + + 361 + 61 + + + + + + + + + 0 + 228 + + + + Qt::NoContextMenu + + + Tool Bar + + + + + + QFrame::StyledPanel + + + QFrame::Plain + + + + 2 + + + + + On Tool Bar + + + + + + + On List Item + + + + + + + Qt::Horizontal + + + + 300 + 16 + + + + + + + + + + + Where do you want to have the buttons for menu? + + + + + + + QFrame::StyledPanel + + + QFrame::Plain + + + + 2 + + + + + On Tool Bar + + + + + + + On List Item + + + + + + + Qt::Horizontal + + + + 300 + 16 + + + + + + + + + + + Where do you want to have the buttons for the page? + + + + + + + + 0 + 0 + + + + QFrame::NoFrame + + + + + + + Icon Only + + + + + Text Only + + + + + Text Beside Icon + + + + + Text Under Icon + + + + + + + + + 0 + 0 + + + + Choose the style of Tool Buttons. + + + + + + + + 0 + 0 + + + + Choose the style of List Items. + + + + + + + + Icon Size = 8x8 + + + + + Icon Size = 16x16 + + + + + Icon Size = 24x24 + + + + + Inon Size = 32x32 + + + + + + + + + Icon Size = 8x8 + + + + + Icon Size = 16x16 + + + + + Icon Size = 24x24 + + + + + Inon Size = 32x32 + + + + + + + + + + diff --git a/retroshare-gui/src/gui/settings/rsettingswin.cpp b/retroshare-gui/src/gui/settings/rsettingswin.cpp index cc75df973..e42813c60 100644 --- a/retroshare-gui/src/gui/settings/rsettingswin.cpp +++ b/retroshare-gui/src/gui/settings/rsettingswin.cpp @@ -54,24 +54,32 @@ int RSettingsWin::lastPage = 0; RSettingsWin::RSettingsWin(QWidget *parent) : QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint) { - setupUi(this); + ui.setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); setModal(false); /* Initialize help browser */ - mHelpBrowser = new FloatingHelpBrowser(this, helpButton); + mHelpBrowser = new FloatingHelpBrowser(this, ui.helpButton); initStackedWidget(); - connect(listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(setNewPage(int))); - connect(buttonBox, SIGNAL(accepted()), this, SLOT(saveChanges())); - connect(buttonBox, SIGNAL(rejected()), this, SLOT(close())); + /* Load window position */ + QByteArray geometry = Settings->valueFromGroup("SettingDialog", "Geometry", QByteArray()).toByteArray(); + if (geometry.isEmpty() == false) { + restoreGeometry(geometry); + } + + connect(ui.listWidget, SIGNAL(currentRowChanged(int)), this, SLOT(setNewPage(int))); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(saveChanges())); + connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect(this, SIGNAL(finished(int)), this, SLOT(dialogFinished(int))); } RSettingsWin::~RSettingsWin() { - lastPage = stackedWidget->currentIndex (); + /* Save window position */ + Settings->setValueToGroup("SettingDialog", "Geometry", saveGeometry()); + lastPage = ui.stackedWidget->currentIndex (); _instance = NULL; } @@ -104,13 +112,13 @@ void RSettingsWin::dialogFinished(int result) /*static*/ void RSettingsWin::postModDirectories(bool update_local) { - if (_instance == NULL || _instance->isHidden() || _instance->stackedWidget == NULL) { + if (_instance == NULL || _instance->isHidden() || _instance->ui.stackedWidget == NULL) { return; } if (update_local) { - if (_instance->stackedWidget->currentIndex() == Directories) { - ConfigPage *Page = dynamic_cast (_instance->stackedWidget->currentWidget()); + if (_instance->ui.stackedWidget->currentIndex() == Directories) { + ConfigPage *Page = dynamic_cast (_instance->ui.stackedWidget->currentWidget()); if (Page) { Page->load(); } @@ -121,8 +129,8 @@ void RSettingsWin::dialogFinished(int result) void RSettingsWin::initStackedWidget() { - stackedWidget->setCurrentIndex(-1); - stackedWidget->removeWidget(stackedWidget->widget(0)); + ui.stackedWidget->setCurrentIndex(-1); + ui.stackedWidget->removeWidget(ui.stackedWidget->widget(0)); addPage(new GeneralPage(0)); addPage(new ServerPage()); @@ -157,16 +165,16 @@ RSettingsWin::initStackedWidget() void RSettingsWin::addPage(ConfigPage *page) { - stackedWidget->addWidget(page) ; + ui.stackedWidget->addWidget(page) ; QListWidgetItem *item = new QListWidgetItem(QIcon(page->iconPixmap()),page->pageName()) ; - listWidget->addItem(item) ; + ui.listWidget->addItem(item) ; } void RSettingsWin::setNewPage(int page) { - ConfigPage *pagew = dynamic_cast(stackedWidget->widget(page)) ; + ConfigPage *pagew = dynamic_cast(ui.stackedWidget->widget(page)) ; mHelpBrowser->hide(); @@ -176,11 +184,11 @@ RSettingsWin::setNewPage(int page) mHelpBrowser->clear(); return ; } - pageName->setText(pagew->pageName()); - pageicon->setPixmap(pagew->iconPixmap()) ; + ui.pageName->setText(pagew->pageName()); + ui.pageicon->setPixmap(pagew->iconPixmap()) ; - stackedWidget->setCurrentIndex(page); - listWidget->setCurrentRow(page); + ui.stackedWidget->setCurrentIndex(page); + ui.listWidget->setCurrentRow(page); mHelpBrowser->setHelpText(pagew->helpText()); } @@ -192,15 +200,15 @@ RSettingsWin::saveChanges() QString errmsg; /* Call each config page's save() method to save its data */ - int i, count = stackedWidget->count(); - for (i = 0; i < count; i++) + int i, count = ui.stackedWidget->count(); + for (i = 0; i < count; i++) { - ConfigPage *page = dynamic_cast(stackedWidget->widget(i)); + ConfigPage *page = dynamic_cast(ui.stackedWidget->widget(i)); if (page && page->wasLoaded()) { if (!page->save(errmsg)) { /* Display the offending page */ - stackedWidget->setCurrentWidget(page); + ui.stackedWidget->setCurrentWidget(page); /* Show the user what went wrong */ QMessageBox::warning(this, diff --git a/retroshare-gui/src/gui/settings/rsettingswin.h b/retroshare-gui/src/gui/settings/rsettingswin.h index f977ff098..98b6101f2 100755 --- a/retroshare-gui/src/gui/settings/rsettingswin.h +++ b/retroshare-gui/src/gui/settings/rsettingswin.h @@ -28,7 +28,7 @@ class FloatingHelpBrowser; -class RSettingsWin: public QDialog, private Ui::Settings +class RSettingsWin: public QDialog { Q_OBJECT @@ -61,6 +61,9 @@ private: FloatingHelpBrowser *mHelpBrowser; static RSettingsWin *_instance; static int lastPage; + + /* UI - from Designer */ + Ui::Settings ui; }; #endif // !RSETTINGSWIN_HPP_ diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index 374853c6f..d6eb9f6e0 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -48,6 +48,7 @@ #define SETTING_ACTIONBUTTONLOC "ActionButtonLocation" #define SETTING_TOOLBUTTONSTYLE "ToolButtonStyle" #define SETTING_TOOLBUTTONSIZE "ToolButtonSize" +#define SETTING_LISTITEMICONSIZE "ListItemIconSize" #define SETTING_DATA_DIRECTORY "DataDirectory" #define SETTING_BWGRAPH_FILTER "StatisticDialog/BWLineFilter" @@ -277,6 +278,45 @@ void RshareSettings::setToolButtonSize(int size) setValue(SETTING_TOOLBUTTONSIZE, 32); } } + +/** Gets the list item icon's size.*/ +int RshareSettings::getListItemIconSize() +{ + int intValue=value(SETTING_LISTITEMICONSIZE, 24).toInt(); + switch (intValue) + { + case 8: + return 8; + case 16: + return 16; + case 24: + default: + return 24; + case 32: + return 32; + } +} + +/** Sets the list item icon's size.*/ +void RshareSettings::setListItemIconSize(int size) +{ + switch (size) + { + case 8: + setValue(SETTING_LISTITEMICONSIZE, 8); + break; + case 16: + setValue(SETTING_LISTITEMICONSIZE, 16); + break; + case 24: + default: + setValue(SETTING_LISTITEMICONSIZE, 24); + break; + case 32: + setValue(SETTING_LISTITEMICONSIZE, 32); + } +} + static QString getKeyForLastDir(RshareSettings::enumLastDir type) { switch (type) { diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index 7d37822b5..bcfea2dfa 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -132,6 +132,11 @@ public: /** Sets the tool button's size.*/ void setToolButtonSize(int size); + /** Gets the list item icon's size.*/ + int getListItemIconSize(); + /** Sets the list item icon's size.*/ + void setListItemIconSize(int size); + /** Returns true if RetroShare's main window should be visible when the * application starts. */ bool getStartMinimized(); diff --git a/retroshare-gui/src/gui/settings/settings.ui b/retroshare-gui/src/gui/settings/settings.ui index ddfc02e74..e77f5d86a 100755 --- a/retroshare-gui/src/gui/settings/settings.ui +++ b/retroshare-gui/src/gui/settings/settings.ui @@ -3,88 +3,41 @@ Settings - - 0 - 0 - 458 - 366 - - - + + 0 + 0 + 820 + 620 + + + Options - :/images/kcmsystem24.png:/images/kcmsystem24.png - - - - - - - 130 - 0 - - - - - 130 - 16777215 - - - - false - - - - 24 - 24 - - - - Qt::ElideMiddle - - - QListView::Static - - - QListView::TopToBottom - - - false - - - QListView::Fixed - - - QListView::SinglePass - - - 0 - - - - 100 - 24 - - - - QListView::ListMode - - - 0 - - - true - - - -1 - - - - - - + :/images/kcmsystem24.png:/images/kcmsystem24.png + + + + + + 6 + + + 0 + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + @@ -140,43 +93,109 @@ Qt::Horizontal - - - - - - - 0 - - - - - - - - Qt::Horizontal - - - - - - - 6 - - - 0 - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - + + + + + + + + 130 + 0 + + + + + 130 + 16777215 + + + + false + + + + 24 + 24 + + + + Qt::ElideMiddle + + + QListView::Static + + + QListView::TopToBottom + + + false + + + QListView::Fixed + + + QListView::SinglePass + + + 0 + + + + 100 + 24 + + + + QListView::ListMode + + + 0 + + + true + + + -1 + + + + + + + Qt::Horizontal + + + + + + + true + + + + + 0 + 0 + 664 + 501 + + + + + + + 0 + + + + + + + + + +