Cleaned ApplicationWindow (unfinished modules).

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5711 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-10-22 13:51:40 +00:00
parent e92ef1a1be
commit 6c784c3062
3 changed files with 40 additions and 1164 deletions

View File

@ -19,13 +19,7 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#include <QtGui> #include <QCloseEvent>
#include <QMessageBox>
#include <QSystemTrayIcon>
#include <QString>
#include <QtDebug>
#include <QIcon>
#include <QPixmap>
#include <rshare.h> #include <rshare.h>
#include "ApplicationWindow.h" #include "ApplicationWindow.h"
@ -49,8 +43,6 @@
//#include "PhotoDialog.h" //#include "PhotoDialog.h"
//#include "StatisticDialog.h" //#include "StatisticDialog.h"
#define FONT QFont("Arial", 9)
/* Images for toolbar icons */ /* Images for toolbar icons */
#define IMAGE_RETROSHARE ":/images/RetroShare16.png" #define IMAGE_RETROSHARE ":/images/RetroShare16.png"
#define IMAGE_ABOUT ":/images/informations_24x24.png" #define IMAGE_ABOUT ":/images/informations_24x24.png"
@ -77,7 +69,6 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
// Setting icons // Setting icons
this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png"))); this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
loadStyleSheet("Default");
/* Create the config pages and actions */ /* Create the config pages and actions */
QActionGroup *grp = new QActionGroup(this); QActionGroup *grp = new QActionGroup(this);
@ -125,21 +116,23 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
#endif #endif
/* Create the toolbar */ /* Create the toolbar */
ui.toolBar->addActions(grp->actions()); ui.toolBar->addActions(grp->actions());
ui.toolBar->addSeparator(); ui.toolBar->addSeparator();
connect(grp, SIGNAL(triggered(QAction *)), ui.stackPages, SLOT(showPage(QAction *))); connect(grp, SIGNAL(triggered(QAction *)), ui.stackPages, SLOT(showPage(QAction *)));
ui.stackPages->setCurrentIndex(0);
} }
/** Creates a new action associated with a config page. */ /** Creates a new action associated with a config page. */
QAction* ApplicationWindow::createPageAction(QIcon img, QString text, QActionGroup *group) QAction* ApplicationWindow::createPageAction(QIcon img, QString text, QActionGroup *group)
{ {
QFont font;
QAction *action = new QAction(img, text, group); QAction *action = new QAction(img, text, group);
font = action->font();
font.setPointSize(9);
action->setCheckable(true); action->setCheckable(true);
action->setFont(FONT); action->setFont(font);
return action; return action;
} }
@ -147,36 +140,13 @@ QAction* ApplicationWindow::createPageAction(QIcon img, QString text, QActionGro
* the specified slot (if given). */ * the specified slot (if given). */
void ApplicationWindow::addAction(QAction *action, const char *slot) void ApplicationWindow::addAction(QAction *action, const char *slot)
{ {
action->setFont(FONT); QFont font = action->font();
font.setPointSize(9);
action->setFont(font);
ui.toolBar->addAction(action); ui.toolBar->addAction(action);
connect(action, SIGNAL(triggered()), this, slot); connect(action, SIGNAL(triggered()), this, slot);
} }
/** Overloads the default show so we can load settings */
void ApplicationWindow::show()
{
if (!this->isVisible()) {
QMainWindow::show();
} else {
QMainWindow::activateWindow();
setWindowState(windowState() & (~Qt::WindowMinimized | Qt::WindowActive));
QMainWindow::raise();
}
}
/** Shows the config dialog with focus set to the given page. */
void ApplicationWindow::show(Page page)
{
/* Show the dialog. */
show();
/* Set the focus to the specified page. */
ui.stackPages->setCurrentIndex((int)page);
}
/** Destructor. */ /** Destructor. */
ApplicationWindow::~ApplicationWindow() ApplicationWindow::~ApplicationWindow()
{ {
@ -184,12 +154,6 @@ ApplicationWindow::~ApplicationWindow()
// delete exampleDialog; // delete exampleDialog;
} }
/** Create and bind actions to events. Setup for initial
* tray menu configuration. */
void ApplicationWindow::createActions()
{
}
void ApplicationWindow::closeEvent(QCloseEvent *e) void ApplicationWindow::closeEvent(QCloseEvent *e)
{ {
//Settings->saveWidgetInformation(this); //Settings->saveWidgetInformation(this);
@ -197,53 +161,3 @@ void ApplicationWindow::closeEvent(QCloseEvent *e)
hide(); hide();
e->ignore(); e->ignore();
} }
void ApplicationWindow::updateMenu()
{
toggleVisibilityAction->setText(isVisible() ? tr("Hide") : tr("Show"));
}
void ApplicationWindow::toggleVisibility(QSystemTrayIcon::ActivationReason e)
{
if(e == QSystemTrayIcon::Trigger || e == QSystemTrayIcon::DoubleClick){
if(isHidden()){
show();
if(isMinimized()){
if(isMaximized()){
showMaximized();
}else{
showNormal();
}
}
raise();
activateWindow();
}else{
hide();
}
}
}
void ApplicationWindow::toggleVisibilitycontextmenu()
{
if (isVisible())
hide();
else
show();
}
void ApplicationWindow::loadStyleSheet(const QString &sheetName)
{
QFile file(":/qss/" + sheetName.toLower() + ".qss");
file.open(QFile::ReadOnly);
QString styleSheet = QLatin1String(file.readAll());
qApp->setStyleSheet(styleSheet);
}

View File

@ -22,34 +22,16 @@
#ifndef _ApplicationWindow_H #ifndef _ApplicationWindow_H
#define _ApplicationWindow_H #define _ApplicationWindow_H
#include <QtGui>
#include <QMainWindow> #include <QMainWindow>
#include <QFileDialog>
#include "ExampleDialog.h"
//#include "ExampleDialog.h"
#include "ui_ApplicationWindow.h" #include "ui_ApplicationWindow.h"
class ApplicationWindow : public QMainWindow class ApplicationWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
public: public:
/** Main dialog pages. */
enum Page {
Graph = 0, /** Network Graph */
Channels = 1, /** Channels page. */
SharedDirectories = 2, /** Shared Directories page. */
Search = 3, /** Search page. */
Transfers = 4, /** Transfers page. */
Chat = 5, /** Chat page. */
Messages = 6, /** Messages page. */
Statistics = 8 /** Statistic page. */
};
/** Default Constructor */ /** Default Constructor */
ApplicationWindow(QWidget *parent = 0, Qt::WFlags flags = 0); ApplicationWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
@ -61,53 +43,22 @@ public:
* Notify Class... * Notify Class...
*/ */
ExampleDialog *exampleDialog; //ExampleDialog *exampleDialog;
//ChannelsDialog *channelsDialog; //ChannelsDialog *channelsDialog;
//GroupsDialog *groupsDialog; //GroupsDialog *groupsDialog;
//StatisticDialog *statisticDialog; //StatisticDialog *statisticDialog;
public slots:
/** Called when this dialog is to be displayed */
void show();
/** Shows the config dialog with focus set to the given page. */
void show(Page page);
private slots:
void updateMenu();
void toggleVisibility(QSystemTrayIcon::ActivationReason e);
void toggleVisibilitycontextmenu();
protected: protected:
void closeEvent(QCloseEvent *); void closeEvent(QCloseEvent *);
private slots:
private: private:
/** Create the actions on the tray menu or menubar */
void createActions();
/** Creates a new action for a config page. */ /** Creates a new action for a config page. */
QAction* createPageAction(QIcon img, QString text, QActionGroup *group); QAction* createPageAction(QIcon img, QString text, QActionGroup *group);
/** Adds a new action to the toolbar. */ /** Adds a new action to the toolbar. */
void addAction(QAction *action, const char *slot = 0); void addAction(QAction *action, const char *slot = 0);
void loadStyleSheet(const QString &sheetName);
QSystemTrayIcon *trayIcon;
QAction *toggleVisibilityAction;
QMenu *menu;
/** Qt Designer generated object */ /** Qt Designer generated object */
Ui::ApplicationWindow ui; Ui::ApplicationWindow ui;
}; };
#endif #endif

File diff suppressed because it is too large Load Diff