mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05:00
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:
parent
e92ef1a1be
commit
6c784c3062
@ -19,13 +19,7 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QtGui>
|
||||
#include <QMessageBox>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QString>
|
||||
#include <QtDebug>
|
||||
#include <QIcon>
|
||||
#include <QPixmap>
|
||||
#include <QCloseEvent>
|
||||
|
||||
#include <rshare.h>
|
||||
#include "ApplicationWindow.h"
|
||||
@ -49,8 +43,6 @@
|
||||
//#include "PhotoDialog.h"
|
||||
//#include "StatisticDialog.h"
|
||||
|
||||
#define FONT QFont("Arial", 9)
|
||||
|
||||
/* Images for toolbar icons */
|
||||
#define IMAGE_RETROSHARE ":/images/RetroShare16.png"
|
||||
#define IMAGE_ABOUT ":/images/informations_24x24.png"
|
||||
@ -77,7 +69,6 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
|
||||
|
||||
// Setting icons
|
||||
this->setWindowIcon(QIcon(QString::fromUtf8(":/images/rstray3.png")));
|
||||
loadStyleSheet("Default");
|
||||
|
||||
/* Create the config pages and actions */
|
||||
QActionGroup *grp = new QActionGroup(this);
|
||||
@ -125,21 +116,23 @@ ApplicationWindow::ApplicationWindow(QWidget* parent, Qt::WFlags flags)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Create the toolbar */
|
||||
ui.toolBar->addActions(grp->actions());
|
||||
ui.toolBar->addSeparator();
|
||||
connect(grp, SIGNAL(triggered(QAction *)), ui.stackPages, SLOT(showPage(QAction *)));
|
||||
|
||||
|
||||
ui.stackPages->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
/** Creates a new action associated with a config page. */
|
||||
QAction* ApplicationWindow::createPageAction(QIcon img, QString text, QActionGroup *group)
|
||||
{
|
||||
QFont font;
|
||||
QAction *action = new QAction(img, text, group);
|
||||
font = action->font();
|
||||
font.setPointSize(9);
|
||||
action->setCheckable(true);
|
||||
action->setFont(FONT);
|
||||
action->setFont(font);
|
||||
return action;
|
||||
}
|
||||
|
||||
@ -147,36 +140,13 @@ QAction* ApplicationWindow::createPageAction(QIcon img, QString text, QActionGro
|
||||
* the specified slot (if given). */
|
||||
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);
|
||||
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. */
|
||||
ApplicationWindow::~ApplicationWindow()
|
||||
{
|
||||
@ -184,12 +154,6 @@ ApplicationWindow::~ApplicationWindow()
|
||||
// delete exampleDialog;
|
||||
}
|
||||
|
||||
/** Create and bind actions to events. Setup for initial
|
||||
* tray menu configuration. */
|
||||
void ApplicationWindow::createActions()
|
||||
{
|
||||
}
|
||||
|
||||
void ApplicationWindow::closeEvent(QCloseEvent *e)
|
||||
{
|
||||
//Settings->saveWidgetInformation(this);
|
||||
@ -197,53 +161,3 @@ void ApplicationWindow::closeEvent(QCloseEvent *e)
|
||||
hide();
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -22,34 +22,16 @@
|
||||
#ifndef _ApplicationWindow_H
|
||||
#define _ApplicationWindow_H
|
||||
|
||||
#include <QtGui>
|
||||
#include <QMainWindow>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "ExampleDialog.h"
|
||||
|
||||
|
||||
//#include "ExampleDialog.h"
|
||||
#include "ui_ApplicationWindow.h"
|
||||
|
||||
|
||||
class ApplicationWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
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 */
|
||||
ApplicationWindow(QWidget *parent = 0, Qt::WFlags flags = 0);
|
||||
|
||||
@ -60,54 +42,23 @@ public:
|
||||
* the dialogs, so we can add them to the
|
||||
* Notify Class...
|
||||
*/
|
||||
|
||||
ExampleDialog *exampleDialog;
|
||||
|
||||
//ExampleDialog *exampleDialog;
|
||||
//ChannelsDialog *channelsDialog;
|
||||
//GroupsDialog *groupsDialog;
|
||||
//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:
|
||||
void closeEvent(QCloseEvent *);
|
||||
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/** Create the actions on the tray menu or menubar */
|
||||
void createActions();
|
||||
|
||||
/** Creates a new action for a config page. */
|
||||
QAction* createPageAction(QIcon img, QString text, QActionGroup *group);
|
||||
/** Adds a new action to the toolbar. */
|
||||
void addAction(QAction *action, const char *slot = 0);
|
||||
|
||||
void loadStyleSheet(const QString &sheetName);
|
||||
|
||||
QSystemTrayIcon *trayIcon;
|
||||
QAction *toggleVisibilityAction;
|
||||
QMenu *menu;
|
||||
|
||||
|
||||
/** Qt Designer generated object */
|
||||
Ui::ApplicationWindow ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user