Merge pull request #668 from csoler/v0.6-ImprovedGUI

V0.6 improved gui
This commit is contained in:
csoler 2017-01-26 22:43:44 +01:00 committed by GitHub
commit 6321bc1818
10 changed files with 168 additions and 64 deletions

View File

@ -425,6 +425,7 @@ void MainWindow::initStackedPage()
addPage(getStartedPage = new GetStartedDialog(ui->stackPages), grp, NULL);
}
#endif
addPage(settingsDialog = new SettingsPage(ui->stackPages),grp,&notify);
/* Create the toolbar */
ui->toolBarPage->addActions(grp->actions());
@ -441,10 +442,11 @@ void MainWindow::initStackedPage()
// I remove add a friend because it's in HOME ghibli
//addAction(new QAction(QIcon(IMAGE_ADDFRIEND), tr("Add"), ui->toolBarAction), &MainWindow::addFriend, SLOT(addFriend()));
//addAction(new QAction(QIcon(IMAGE_NEWRSCOLLECTION), tr("New"), ui->toolBarAction), &MainWindow::newRsCollection, SLOT(newRsCollection()));
addAction(new QAction(QIcon(IMAGE_PREFERENCES), tr("Options"), ui->toolBarAction), &MainWindow::showSettings, SLOT(showSettings()));
//addAction(new QAction(QIcon(IMAGE_PREFERENCES), tr("Options"), ui->toolBarAction), &MainWindow::showSettings, SLOT(showSettings()));
// Removed About because it's now in options.
//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<QPair<MainPage*, QPair<QAction*, QListWidgetItem*> > >::iterator notifyIt;
@ -768,11 +770,7 @@ void MainWindow::updateFriends()
void MainWindow::postModDirectories(bool update_local)
{
RSettingsWin::postModDirectories(update_local);
// Why would we need that?? The effect is to reset the flags while we're changing them, so it's really not
// a good idea.
//ShareManager::postModDirectories(update_local);
//RSettingsPage::postModDirectories(update_local);
QCoreApplication::flush();
}
@ -901,6 +899,9 @@ void SetForegroundWindowInternal(HWND hWnd)
_instance->ui->stackPages->setCurrentPage( _instance->transfersDialog );
_instance->transfersDialog->activatePage(TransfersDialog::LocalSharedFilesTab) ;
break;
case Options:
_instance->ui->stackPages->setCurrentPage( _instance->settingsDialog );
break;
case Messages:
_instance->ui->stackPages->setCurrentPage( _instance->messagesDialog );
break;
@ -940,6 +941,9 @@ void SetForegroundWindowInternal(HWND hWnd)
if (page == _instance->friendsDialog) {
return Friends;
}
if (page == _instance->settingsDialog) {
return Options;
}
if (page == _instance->chatLobbyDialog) {
return ChatLobby;
}
@ -991,6 +995,8 @@ void SetForegroundWindowInternal(HWND hWnd)
return _instance->idDialog;
case ChatLobby:
return _instance->chatLobbyDialog;
case Options:
return _instance->settingsDialog;
case Transfers:
return _instance->transfersDialog;
case SharedDirectories:
@ -1054,7 +1060,7 @@ MainWindow::showMess()
/** Shows Options */
void MainWindow::showSettings()
{
RSettingsWin::showYourself(this);
showWindow(MainWindow::Options);
}
/** Shows Messenger window */
@ -1484,6 +1490,29 @@ void MainWindow::processLastArgs()
}
}
void MainWindow::switchVisibilityStatus(StatusElement e,bool b)
{
switch(e)
{
case StatusGrpStatus : getInstance()->statusBar() ->setVisible(b); break ;
case StatusCompactMode : getInstance()->setCompactStatusMode(b) ; break ;
case StatusShowToolTip : getInstance()->toggleStatusToolTip(b) ; break ;
case StatusShowStatus : getInstance()->peerstatusInstance() ->setVisible(b); break ;
case StatusShowPeer : getInstance()->natstatusInstance() ->setVisible(b); break ;
case StatusShowDHT : getInstance()->dhtstatusInstance() ->setVisible(b); break ;
case StatusShowHashing : getInstance()->hashingstatusInstance() ->setVisible(b); break ;
case StatusShowDisc : getInstance()->discstatusInstance() ->setVisible(b); break ;
case StatusShowRate : getInstance()->ratesstatusInstance() ->setVisible(b); break ;
case StatusShowOpMode : getInstance()->opModeStatusInstance() ->setVisible(b); break ;
case StatusShowSound : getInstance()->soundStatusInstance() ->setVisible(b); break ;
case StatusShowToaster : getInstance()->toasterDisableInstance() ->setVisible(b); break ;
case StatusShowSystray : getInstance()->sysTrayStatusInstance() ->setVisible(b); break ;
default:
std::cerr << "(EE) Unknown object to change visibility of: " << (int)e << std::endl;
}
}
//void MainWindow::servicePermission()
//{
// ServicePermissionDialog::showYourself();

View File

@ -53,6 +53,7 @@ class PostedDialog;
class FriendsDialog;
class IdDialog;
class ChatLobbyWidget;
class SettingsPage ;
class ChatDialog;
class NetworkDialog;
class SearchDialog;
@ -104,7 +105,25 @@ public:
Links = 10, /** Links page. */
#endif
Posted = 11, /** Posted links */
People = 12 /** People page. */
People = 12, /** People page. */
Options = 13 /** People page. */
};
enum StatusElement {
StatusGrpStatus = 0x01,
StatusCompactMode = 0x02,
StatusShowToolTip = 0x03,
StatusShowStatus = 0x04,
StatusShowPeer = 0x05,
StatusShowDHT = 0x06,
StatusShowHashing = 0x07,
StatusShowDisc = 0x08,
StatusShowRate = 0x09,
StatusShowOpMode = 0x0a,
StatusShowSound = 0x0b,
StatusShowToaster = 0x0c,
StatusShowSystray = 0x0d
};
/** Create main window */
@ -142,6 +161,7 @@ public:
IdDialog *idDialog ;
ChatLobbyWidget *chatLobbyDialog;
MessagesDialog *messagesDialog;
SettingsPage *settingsDialog;
SharedFilesDialog *sharedfilesDialog;
GxsChannelDialog *gxschannelDialog ;
GxsForumsDialog *gxsforumDialog ;
@ -168,6 +188,8 @@ public:
static void installNotifyIcons();
static void displayLobbySystrayMsg(const QString&,const QString&);
static void switchVisibilityStatus(MainWindow::StatusElement e,bool b);
/* initialize widget with status informations, status constant stored in data or in Qt::UserRole */
void initializeStatusObject(QObject *pObject, bool bConnect);
void removeStatusObject(QObject *pObject);

View File

@ -1396,5 +1396,5 @@ void NewsFeed::sendNewsFeedChanged()
void NewsFeed::feedoptions()
{
RSettingsWin::showYourself(this, RSettingsWin::Notify);
SettingsPage::showYourself(this, SettingsPage::Notify);
}

View File

@ -1006,10 +1006,10 @@ void ChatWidget::pasteText(const QString& S)
setColorAndFont(false);
}
void ChatWidget::pasteCreateMsgLink()
{
RSettingsWin::showYourself(this, RSettingsWin::Chat);
}
//void ChatWidget::pasteCreateMsgLink()
//{
// RSettingsWin::showYourself(this, RSettingsWin::Chat);
//}
void ChatWidget::contextMenuTextBrowser(QPoint point)
{

View File

@ -127,7 +127,7 @@ public slots:
void updateStatus(const QString &peer_id, int status);
private slots:
void pasteCreateMsgLink() ;
//void pasteCreateMsgLink() ;
void clearChatHistory();
void deleteChatHistory();
void messageHistory();

View File

@ -49,23 +49,22 @@ AppearancePage::AppearancePage(QWidget * parent, Qt::WindowFlags flags)
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
MainWindow *pMainWindow = MainWindow::getInstance();
connect(ui.cmboStyleSheet, SIGNAL(activated(int)), this, SLOT(loadStyleSheet(int)));
connect(ui.grpStatus, SIGNAL(toggled(bool)), pMainWindow->statusBar(), SLOT(setVisible(bool)));
connect(ui.checkBoxStatusCompactMode, SIGNAL(toggled(bool)), pMainWindow, SLOT(setCompactStatusMode(bool)));
connect(ui.checkBoxDisableSysTrayToolTip, SIGNAL(toggled(bool)), pMainWindow, SLOT(toggleStatusToolTip(bool)));
connect(ui.checkBoxShowStatusStatus, SIGNAL(toggled(bool)), pMainWindow->statusComboBoxInstance(), SLOT(setVisible(bool)));
connect(ui.checkBoxShowPeerStatus, SIGNAL(toggled(bool)), pMainWindow->peerstatusInstance(), SLOT(setVisible(bool)));
connect(ui.checkBoxShowNATStatus, SIGNAL(toggled(bool)), pMainWindow->natstatusInstance(), SLOT(setVisible(bool)));
connect(ui.checkBoxShowDHTStatus, SIGNAL(toggled(bool)), pMainWindow->dhtstatusInstance(), SLOT(setVisible(bool)));
connect(ui.checkBoxShowHashingStatus, SIGNAL(toggled(bool)), pMainWindow->hashingstatusInstance(), SLOT(setVisible(bool)));
connect(ui.checkBoxShowDiscStatus, SIGNAL(toggled(bool)), pMainWindow->discstatusInstance(), SLOT(setVisible(bool)));
connect(ui.checkBoxShowRateStatus, SIGNAL(toggled(bool)), pMainWindow->ratesstatusInstance(), SLOT(setVisible(bool)));
connect(ui.checkBoxShowOpModeStatus, SIGNAL(toggled(bool)), pMainWindow->opModeStatusInstance(), SLOT(setVisible(bool)));
connect(ui.checkBoxShowSoundStatus, SIGNAL(toggled(bool)), pMainWindow->soundStatusInstance(), SLOT(setVisible(bool)));
connect(ui.checkBoxShowToasterDisable, SIGNAL(toggled(bool)), pMainWindow->toasterDisableInstance(), SLOT(setVisible(bool)));
connect(ui.checkBoxShowSystrayOnStatus, SIGNAL(toggled(bool)), pMainWindow->sysTrayStatusInstance(), SLOT(setVisible(bool)));
connect(ui.grpStatus, SIGNAL(toggled(bool)), this /* pMainWindow->statusBar(), */, SLOT(switch_status_grpStatus(bool)));
connect(ui.checkBoxStatusCompactMode, SIGNAL(toggled(bool)), this /* pMainWindow, */, SLOT(switch_status_compactMode(bool)));
connect(ui.checkBoxDisableSysTrayToolTip, SIGNAL(toggled(bool)), this /* pMainWindow, */, SLOT(switch_status_showToolTip(bool)));
connect(ui.checkBoxShowStatusStatus, SIGNAL(toggled(bool)), this /* pMainWindow->statusComboBoxInstance(), */, SLOT(switch_status_ShowStatus(bool)));
connect(ui.checkBoxShowPeerStatus, SIGNAL(toggled(bool)), this /* pMainWindow->peerstatusInstance(), */, SLOT(switch_status_ShowStatus(bool)));
connect(ui.checkBoxShowNATStatus, SIGNAL(toggled(bool)), this /* pMainWindow->natstatusInstance(), */, SLOT(switch_status_ShowPeer(bool)));
connect(ui.checkBoxShowDHTStatus, SIGNAL(toggled(bool)), this /* pMainWindow->dhtstatusInstance(), */, SLOT(switch_status_ShowDHT(bool)));
connect(ui.checkBoxShowHashingStatus, SIGNAL(toggled(bool)), this /* pMainWindow->hashingstatusInstance(), */, SLOT(switch_status_ShowHashing(bool)));
connect(ui.checkBoxShowDiscStatus, SIGNAL(toggled(bool)), this /* pMainWindow->discstatusInstance(), */, SLOT(switch_status_ShowDisc(bool)));
connect(ui.checkBoxShowRateStatus, SIGNAL(toggled(bool)), this /* pMainWindow->ratesstatusInstance(), */, SLOT(switch_status_ShowRate(bool)));
connect(ui.checkBoxShowOpModeStatus, SIGNAL(toggled(bool)), this /* pMainWindow->opModeStatusInstance(), */, SLOT(switch_status_ShowOpMode(bool)));
connect(ui.checkBoxShowSoundStatus, SIGNAL(toggled(bool)), this /* pMainWindow->soundStatusInstance(), */, SLOT(switch_status_ShowSound(bool)));
connect(ui.checkBoxShowToasterDisable, SIGNAL(toggled(bool)), this /* pMainWindow->toasterDisableInstance(), */, SLOT(switch_status_ShowToaster(bool)));
connect(ui.checkBoxShowSystrayOnStatus, SIGNAL(toggled(bool)), this /* pMainWindow->sysTrayStatusInstance(), */, SLOT(switch_status_ShowSystray(bool)));
/* Populate combo boxes */
foreach (QString code, LanguageSupport::languageCodes()) {
@ -86,6 +85,30 @@ AppearancePage::AppearancePage(QWidget * parent, Qt::WindowFlags flags)
}
}
void AppearancePage::switch_status_grpStatus(bool b) { switch_status(MainWindow::StatusGrpStatus ,b) ; }
void AppearancePage::switch_status_compactMode(bool b) { switch_status(MainWindow::StatusCompactMode,b) ; }
void AppearancePage::switch_status_showToolTip(bool b) { switch_status(MainWindow::StatusShowToolTip,b) ; }
void AppearancePage::switch_status_ShowStatus(bool b) { switch_status(MainWindow::StatusShowStatus ,b) ; }
void AppearancePage::switch_status_ShowPeer(bool b) { switch_status(MainWindow::StatusShowPeer ,b) ; }
void AppearancePage::switch_status_ShowDHT(bool b) { switch_status(MainWindow::StatusShowDHT ,b) ; }
void AppearancePage::switch_status_ShowHashing(bool b) { switch_status(MainWindow::StatusShowHashing,b) ; }
void AppearancePage::switch_status_ShowDisc(bool b) { switch_status(MainWindow::StatusShowDisc ,b) ; }
void AppearancePage::switch_status_ShowRate(bool b) { switch_status(MainWindow::StatusShowRate ,b) ; }
void AppearancePage::switch_status_ShowOpMode(bool b) { switch_status(MainWindow::StatusShowOpMode ,b) ; }
void AppearancePage::switch_status_ShowSound(bool b) { switch_status(MainWindow::StatusShowSound ,b) ; }
void AppearancePage::switch_status_ShowToaster(bool b) { switch_status(MainWindow::StatusShowToaster,b) ; }
void AppearancePage::switch_status_ShowSystray(bool b) { switch_status(MainWindow::StatusShowSystray,b) ; }
void AppearancePage::switch_status(MainWindow::StatusElement s,bool b)
{
MainWindow *pMainWindow = MainWindow::getInstance();
if(!pMainWindow)
return ;
pMainWindow->switchVisibilityStatus(s,b) ;
}
/** Saves the changes on this page */
bool AppearancePage::save(QString &errmsg)
{

View File

@ -23,6 +23,7 @@
#define _APPERARANCEPAGE_H
#include <retroshare-gui/configpage.h>
#include "gui/MainWindow.h"
#include "ui_AppearancePage.h"
class AppearancePage : public ConfigPage
@ -45,7 +46,23 @@ public:
private slots:
void loadStyleSheet(int index);
void switch_status_grpStatus(bool b) ;
void switch_status_compactMode(bool b) ;
void switch_status_showToolTip(bool b) ;
void switch_status_ShowStatus(bool) ;
void switch_status_ShowPeer(bool) ;
void switch_status_ShowDHT(bool) ;
void switch_status_ShowHashing(bool) ;
void switch_status_ShowDisc(bool) ;
void switch_status_ShowRate(bool) ;
void switch_status_ShowOpMode(bool) ;
void switch_status_ShowSound(bool) ;
void switch_status_ShowToaster(bool) ;
void switch_status_ShowSystray(bool) ;
private:
void switch_status(MainWindow::StatusElement s,bool b);
/** Qt Designer generated object */
Ui::AppearancePage ui;
};

View File

@ -52,15 +52,15 @@
#include "rsettingswin.h"
RSettingsWin *RSettingsWin::_instance = NULL;
int RSettingsWin::lastPage = 0;
//RSettingsWin *RSettingsWin::_instance = NULL;
int SettingsPage::lastPage = 0;
RSettingsWin::RSettingsWin(QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)
SettingsPage::SettingsPage(QWidget *parent)
: MainPage(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)
{
ui.setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
setModal(false);
// setModal(false);
/* Initialize help browser */
mHelpBrowser = new FloatingHelpBrowser(this, ui.helpButton);
@ -74,31 +74,32 @@ RSettingsWin::RSettingsWin(QWidget *parent)
}
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(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()
SettingsPage::~SettingsPage()
{
/* Save window position */
Settings->setValueToGroup("SettingDialog", "Geometry", saveGeometry());
lastPage = ui.stackedWidget->currentIndex ();
_instance = NULL;
//_instance = NULL;
}
void RSettingsWin::dialogFinished(int result)
{
if (result == Rejected) {
/* reaload style sheet */
Rshare::loadStyleSheet(::Settings->getSheetName());
}
}
//void RSettingsPage::dialogFinished(int result)
//{
// if (result == Rejected) {
// /* reaload style sheet */
// Rshare::loadStyleSheet(::Settings->getSheetName());
// }
//}
/*static*/ void RSettingsWin::showYourself(QWidget *parent, PageType page /* = LastPage*/)
/*static*/ void SettingsPage::showYourself(QWidget *parent, PageType page /* = LastPage*/)
{
#ifdef TODO
if(_instance == NULL) {
_instance = new RSettingsWin(parent);
_instance = new RSettingsPage(parent);
}
if (page != LastPage) {
@ -112,17 +113,21 @@ void RSettingsWin::dialogFinished(int result)
_instance->show();
_instance->activateWindow();
#else
std::cerr << "(EE) unimplemented call to RSettingsPage::showYourself" << std::endl;
#endif
}
/*static*/ void RSettingsWin::postModDirectories(bool update_local)
/*static*/ void SettingsPage::postModDirectories(bool update_local)
{
if (_instance == NULL || _instance->isHidden() || _instance->ui.stackedWidget == NULL) {
//if (_instance == NULL || _instance->isHidden() || _instance->ui.stackedWidget == NULL) {
if (ui.stackedWidget == NULL) {
return;
}
if (update_local) {
if (_instance->ui.stackedWidget->currentIndex() == Directories) {
ConfigPage *Page = dynamic_cast<ConfigPage *> (_instance->ui.stackedWidget->currentWidget());
if (ui.stackedWidget->currentIndex() == Directories) {
ConfigPage *Page = dynamic_cast<ConfigPage *> (ui.stackedWidget->currentWidget());
if (Page) {
Page->load();
}
@ -131,7 +136,7 @@ void RSettingsWin::dialogFinished(int result)
}
void
RSettingsWin::initStackedWidget()
SettingsPage::initStackedWidget()
{
ui.stackedWidget->setCurrentIndex(-1);
ui.stackedWidget->removeWidget(ui.stackedWidget->widget(0));
@ -175,7 +180,7 @@ RSettingsWin::initStackedWidget()
setNewPage(General);
}
void RSettingsWin::addPage(ConfigPage *page)
void SettingsPage::addPage(ConfigPage *page)
{
ui.stackedWidget->addWidget(page) ;
@ -184,7 +189,7 @@ void RSettingsWin::addPage(ConfigPage *page)
}
void
RSettingsWin::setNewPage(int page)
SettingsPage::setNewPage(int page)
{
ConfigPage *pagew = dynamic_cast<ConfigPage*>(ui.stackedWidget->widget(page)) ;
@ -192,7 +197,7 @@ RSettingsWin::setNewPage(int page)
if(pagew == NULL)
{
std::cerr << "Error in RSettingsWin::setNewPage(): widget is not a ConfigPage!" << std::endl;
std::cerr << "Error in RSettingsPage::setNewPage(): widget is not a ConfigPage!" << std::endl;
mHelpBrowser->clear();
return ;
}
@ -207,7 +212,7 @@ RSettingsWin::setNewPage(int page)
/** Saves changes made to settings. */
void
RSettingsWin::saveChanges()
SettingsPage::saveChanges()
{
QString errmsg;

View File

@ -24,24 +24,32 @@
#include <QDialog>
#include <retroshare-gui/configpage.h>
#include "ui_settings.h"
#include "ui_settingsw.h"
#include "mainpage.h"
class FloatingHelpBrowser;
class RSettingsWin: public QDialog
#define IMAGE_PREFERENCES ":/icons/png/options.png"
class SettingsPage: public MainPage
{
Q_OBJECT
public:
SettingsPage(QWidget *parent = 0);
enum PageType { LastPage = -1, General = 0, Server, Transfer,Relay,
Directories, Plugins, Notify, Security, Message, Forum, Chat, Appearance, Sound, Fileassociations };
static void showYourself(QWidget *parent, PageType page = LastPage);
static void postModDirectories(bool update_local);
void postModDirectories(bool update_local);
virtual QIcon iconPixmap() const { return QIcon(IMAGE_PREFERENCES) ; } //MainPage
virtual QString pageName() const { return tr("Preferences") ; } //MainPage
protected:
RSettingsWin(QWidget *parent = 0);
~RSettingsWin();
~SettingsPage();
void addPage(ConfigPage*) ;
@ -52,14 +60,14 @@ public slots:
private slots:
/** Called when user clicks "Save Settings" */
void saveChanges();
void dialogFinished(int result);
//void dialogFinished(int result);
private:
void initStackedWidget();
private:
FloatingHelpBrowser *mHelpBrowser;
static RSettingsWin *_instance;
//static RSettingsWin *_instance;
static int lastPage;
/* UI - from Designer */

View File

@ -624,7 +624,7 @@ FORMS += gui/StartDialog.ui \
gui/msgs/MessageComposer.ui \
gui/msgs/MessageWindow.ui\
gui/msgs/MessageWidget.ui\
gui/settings/settings.ui \
gui/settings/settingsw.ui \
gui/settings/GeneralPage.ui \
gui/settings/DirectoriesPage.ui \
gui/settings/ServerPage.ui \