mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added systray menu in status bar. Helps people without a systray (Patch form Phenom)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7660 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d07a26f96d
commit
a3736a02d2
@ -84,6 +84,7 @@
|
||||
#include "statusbar/OpModeStatus.h"
|
||||
#include "statusbar/SoundStatus.h"
|
||||
#include "statusbar/ToasterDisable.h"
|
||||
#include "statusbar/SysTrayStatus.h"
|
||||
#include <retroshare/rsstatus.h>
|
||||
|
||||
#include <retroshare/rsiface.h>
|
||||
@ -274,6 +275,11 @@ MainWindow::MainWindow(QWidget* parent, Qt::WindowFlags flags)
|
||||
toasterDisable->setHidden(Settings->valueFromGroup("StatusBar", "HideToaster", QVariant(false)).toBool());
|
||||
statusBar()->addPermanentWidget(toasterDisable);
|
||||
|
||||
sysTrayStatus = new SysTrayStatus();
|
||||
sysTrayStatus->setVisible(Settings->valueFromGroup("StatusBar", "ShowSysTrayOnStatusBar", QVariant(false)).toBool());
|
||||
statusBar()->addPermanentWidget(sysTrayStatus);
|
||||
|
||||
|
||||
setCompactStatusMode(Settings->valueFromGroup("StatusBar", "CompactMode", QVariant(false)).toBool());
|
||||
|
||||
/** Status Bar end ******/
|
||||
@ -322,6 +328,7 @@ MainWindow::~MainWindow()
|
||||
delete opModeStatus;
|
||||
delete soundStatus;
|
||||
delete toasterDisable;
|
||||
delete sysTrayStatus;
|
||||
MessengerWindow::releaseInstance();
|
||||
#ifdef UNFINISHED
|
||||
delete applicationWindow;
|
||||
@ -596,8 +603,10 @@ void MainWindow::createTrayIcon()
|
||||
{
|
||||
/** Tray icon Menu **/
|
||||
QMenu *trayMenu = new QMenu(this);
|
||||
if (sysTrayStatus) sysTrayStatus->trayMenu = trayMenu;
|
||||
QObject::connect(trayMenu, SIGNAL(aboutToShow()), this, SLOT(updateMenu()));
|
||||
toggleVisibilityAction = trayMenu->addAction(QIcon(IMAGE_RETROSHARE), tr("Show/Hide"), this, SLOT(toggleVisibilitycontextmenu()));
|
||||
if (sysTrayStatus) sysTrayStatus->toggleVisibilityAction = toggleVisibilityAction;
|
||||
|
||||
/* Create status menu */
|
||||
QMenu *statusMenu = trayMenu->addMenu(tr("Status"));
|
||||
@ -802,6 +811,7 @@ void MainWindow::updateFriends()
|
||||
}
|
||||
|
||||
if (trayIcon) trayIcon->setIcon(icon);
|
||||
if (sysTrayStatus) sysTrayStatus->setIcon(icon);
|
||||
}
|
||||
|
||||
void MainWindow::postModDirectories(bool update_local)
|
||||
@ -1483,6 +1493,11 @@ ToasterDisable *MainWindow::toasterDisableInstance()
|
||||
return toasterDisable;
|
||||
}
|
||||
|
||||
SysTrayStatus *MainWindow::sysTrayStatusInstance()
|
||||
{
|
||||
return sysTrayStatus;
|
||||
}
|
||||
|
||||
void MainWindow::setCompactStatusMode(bool compact)
|
||||
{
|
||||
//statusComboBox: TODO Show only icon
|
||||
|
@ -45,6 +45,7 @@ class RatesStatus;
|
||||
class OpModeStatus;
|
||||
class SoundStatus;
|
||||
class ToasterDisable;
|
||||
class SysTrayStatus;
|
||||
//class ForumsDialog;
|
||||
class GxsChannelDialog ;
|
||||
class GxsForumsDialog ;
|
||||
@ -169,6 +170,7 @@ public:
|
||||
|
||||
SoundStatus *soundStatusInstance();
|
||||
ToasterDisable *toasterDisableInstance();
|
||||
SysTrayStatus *sysTrayStatusInstance();
|
||||
|
||||
public slots:
|
||||
void displayErrorMessage(int,int,const QString&) ;
|
||||
@ -268,6 +270,7 @@ private:
|
||||
OpModeStatus *opModeStatus;
|
||||
SoundStatus *soundStatus;
|
||||
ToasterDisable *toasterDisable;
|
||||
SysTrayStatus *sysTrayStatus;
|
||||
|
||||
/* Status */
|
||||
std::set <QObject*> m_apStatusObjects; // added objects for status
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "gui/MainWindow.h"
|
||||
#include "gui/statusbar/SoundStatus.h"
|
||||
#include "gui/statusbar/ToasterDisable.h"
|
||||
#include "gui/statusbar/SysTrayStatus.h"
|
||||
|
||||
/** Constructor */
|
||||
AppearancePage::AppearancePage(QWidget * parent, Qt::WindowFlags flags)
|
||||
@ -43,6 +44,7 @@ AppearancePage::AppearancePage(QWidget * parent, Qt::WindowFlags flags)
|
||||
connect(ui.checkBoxStatusCompactMode, SIGNAL(toggled(bool)), pMainWindow, SLOT(setCompactStatusMode(bool)));
|
||||
connect(ui.checkBoxHideSoundStatus, SIGNAL(toggled(bool)), pMainWindow->soundStatusInstance(), SLOT(setHidden(bool)));
|
||||
connect(ui.checkBoxHideToasterDisable, SIGNAL(toggled(bool)), pMainWindow->toasterDisableInstance(), SLOT(setHidden(bool)));
|
||||
connect(ui.checkBoxShowSystrayOnStatus, SIGNAL(toggled(bool)), pMainWindow->sysTrayStatusInstance(), SLOT(setVisible(bool)));
|
||||
|
||||
/* Populate combo boxes */
|
||||
foreach (QString code, LanguageSupport::languageCodes()) {
|
||||
@ -131,6 +133,7 @@ bool AppearancePage::save(QString &errmsg)
|
||||
Settings->setValueToGroup("StatusBar", "CompactMode", QVariant(ui.checkBoxStatusCompactMode->isChecked()));
|
||||
Settings->setValueToGroup("StatusBar", "HideSound", QVariant(ui.checkBoxHideSoundStatus->isChecked()));
|
||||
Settings->setValueToGroup("StatusBar", "HideToaster", QVariant(ui.checkBoxHideToasterDisable->isChecked()));
|
||||
Settings->setValueToGroup("StatusBar", "ShowSysTrayOnStatusBar", QVariant(ui.checkBoxShowSystrayOnStatus->isChecked()));
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -204,6 +207,7 @@ void AppearancePage::load()
|
||||
ui.checkBoxStatusCompactMode->setChecked(Settings->valueFromGroup("StatusBar", "CompactMode", QVariant(false)).toBool());
|
||||
ui.checkBoxHideSoundStatus->setChecked(Settings->valueFromGroup("StatusBar", "HideSound", QVariant(false)).toBool());
|
||||
ui.checkBoxHideToasterDisable->setChecked(Settings->valueFromGroup("StatusBar", "HideToaster", QVariant(false)).toBool());
|
||||
ui.checkBoxShowSystrayOnStatus->setChecked(Settings->valueFromGroup("StatusBar", "ShowSysTrayOnStatusBar", QVariant(false)).toBool());
|
||||
|
||||
}
|
||||
|
||||
|
@ -434,6 +434,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxShowSystrayOnStatus">
|
||||
<property name="text">
|
||||
<string>Show SysTray on Status Bar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
64
retroshare-gui/src/gui/statusbar/SysTrayStatus.cpp
Normal file
64
retroshare-gui/src/gui/statusbar/SysTrayStatus.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QAction>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "SysTrayStatus.h"
|
||||
|
||||
#define IMAGE_NOONLINE ":/images/logo/logo_24_0.png"
|
||||
#define IMAGE_ONEONLINE ":/images/logo/logo_24_1.png"
|
||||
#define IMAGE_TWOONLINE ":/images/logo/logo_24_2.png"
|
||||
|
||||
SysTrayStatus::SysTrayStatus(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
QHBoxLayout *hbox = new QHBoxLayout(this);
|
||||
hbox->setMargin(0);
|
||||
hbox->setSpacing(0);
|
||||
|
||||
imageButton = new QPushButton(this);
|
||||
imageButton->setIcon(QIcon(IMAGE_NOONLINE));
|
||||
imageButton->setFlat(true);
|
||||
imageButton->setCheckable(false);
|
||||
imageButton->setMaximumSize(24, 24);
|
||||
imageButton->setFocusPolicy(Qt::ClickFocus);
|
||||
hbox->addWidget(imageButton);
|
||||
|
||||
setLayout(hbox);
|
||||
|
||||
trayMenu = NULL;
|
||||
toggleVisibilityAction = NULL;
|
||||
|
||||
connect(imageButton, SIGNAL(clicked()), this, SLOT(showMenu()));
|
||||
}
|
||||
void SysTrayStatus::setIcon(const QIcon &icon)
|
||||
{
|
||||
imageButton->setIcon(icon);
|
||||
}
|
||||
|
||||
void SysTrayStatus::showMenu()
|
||||
{
|
||||
if(toggleVisibilityAction) toggleVisibilityAction->setVisible(false);
|
||||
if(trayMenu) trayMenu->exec(QCursor::pos());
|
||||
if(toggleVisibilityAction) toggleVisibilityAction->setVisible(true);
|
||||
}
|
48
retroshare-gui/src/gui/statusbar/SysTrayStatus.h
Normal file
48
retroshare-gui/src/gui/statusbar/SysTrayStatus.h
Normal file
@ -0,0 +1,48 @@
|
||||
/****************************************************************
|
||||
* RetroShare is distributed under the following license:
|
||||
*
|
||||
* Copyright (C) 2012 RetroShare Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#ifndef SYSTRAYSTATUS_H
|
||||
#define SYSTRAYSTATUS_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMenu>
|
||||
|
||||
class QPushButton;
|
||||
|
||||
class SysTrayStatus : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SysTrayStatus(QWidget *parent = 0);
|
||||
void setIcon(const QIcon &icon);
|
||||
|
||||
QMenu *trayMenu;
|
||||
QAction *toggleVisibilityAction;
|
||||
|
||||
private slots:
|
||||
void showMenu();
|
||||
|
||||
private:
|
||||
QPushButton *imageButton;
|
||||
};
|
||||
|
||||
#endif // SYSTRAYSTATUS_H
|
@ -492,6 +492,7 @@ HEADERS += rshare.h \
|
||||
gui/statusbar/SoundStatus.h \
|
||||
gui/statusbar/OpModeStatus.h \
|
||||
gui/statusbar/ToasterDisable.h \
|
||||
gui/statusbar/SysTrayStatus.h \
|
||||
gui/advsearch/advancedsearchdialog.h \
|
||||
gui/advsearch/expressionwidget.h \
|
||||
gui/advsearch/guiexprelement.h \
|
||||
@ -810,6 +811,7 @@ SOURCES += main.cpp \
|
||||
gui/statusbar/SoundStatus.cpp \
|
||||
gui/statusbar/OpModeStatus.cpp \
|
||||
gui/statusbar/ToasterDisable.cpp \
|
||||
gui/statusbar/SysTrayStatus.cpp \
|
||||
gui/toaster/MessageToaster.cpp \
|
||||
gui/toaster/DownloadToaster.cpp \
|
||||
gui/toaster/OnlineToaster.cpp \
|
||||
|
Loading…
Reference in New Issue
Block a user