19
19
#include "baseguiplus.h"
21
#ifdef USE_SYSTEM_TRAY
21
23
#if QT_VERSION >= 0x040200
22
24
#include <Q3PopupMenu>
26
#include <qpopupmenu.h>
27
#include "mysystemtrayicon.h"
23
30
#include "myaction.h"
24
31
#include "global.h"
25
32
#include "images.h"
26
#include "playlist2.h"
27
34
//#include "infowindow.h"
31
BaseGuiPlus::BaseGuiPlus( QString file, QWidget * parent, const char* name,
38
BaseGuiPlus::BaseGuiPlus( QStringList files, QWidget * parent, const char* name,
33
: BaseGui( file, parent, name, fl )
40
: BaseGui( files, parent, name, fl )
35
#if QT_VERSION >= 0x040200
42
#ifdef USE_SYSTEM_TRAY
36
43
mainwindow_visible = true;
37
44
playlist_visible = false;
38
45
//infowindow_visible = false;
39
46
mainwindow_pos = pos();
48
#if QT_VERSION >= 0x040200
41
49
tray = new QSystemTrayIcon( Images::icon("logo", 22), this );
51
tray = new MySystemTrayIcon( Images::icon("logo", 22), this );
42
54
tray->setToolTip( "SMPlayer" );
43
55
connect( tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
44
56
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
58
quitAct = new MyAction(this, "quit");
59
connect( quitAct, SIGNAL(activated()), this, SLOT(quit()) );
46
60
quitAct->addTo( openMenu );
48
62
showTrayAct = new MyAction(this, "show_try_icon" );
55
69
connect( showAllAct, SIGNAL(activated()),
56
70
this, SLOT(toggleShowAll()) );
58
context_menu = new Q3PopupMenu(this);
72
context_menu = new QPopupMenu(this);
59
74
showAllAct->addTo( context_menu );
60
context_menu->addSeparator();
75
context_menu->insertSeparator();
61
76
openFileAct->addTo( context_menu );
62
77
recents_menu_id = context_menu->insertItem( "Recents", recentfiles_menu );
63
78
openDVDAct->addTo( context_menu );
64
79
openURLAct->addTo( context_menu );
65
context_menu->addSeparator();
80
context_menu->insertSeparator();
66
81
playOrPauseAct->addTo( context_menu );
67
82
stopAct->addTo( context_menu );
68
context_menu->addSeparator();
69
playlist->playPrevAct()->addTo( context_menu );
70
playlist->playNextAct()->addTo( context_menu );
71
context_menu->addSeparator();
83
context_menu->insertSeparator();
84
playPrevAct->addTo( context_menu );
85
playNextAct->addTo( context_menu );
86
context_menu->insertSeparator();
72
87
showPlaylistAct->addTo( context_menu );
73
88
showPreferencesAct->addTo( context_menu );
74
context_menu->addSeparator();
89
context_menu->insertSeparator();
75
90
quitAct->addTo( context_menu );
77
92
tray->setContextMenu( context_menu );
89
104
void BaseGuiPlus::firstShow() {
90
105
qDebug("BaseGuiPlus::firstShow");
91
#if QT_VERSION >= 0x040200
92
if ( (!showTrayAct->isOn()) || (!initial_file.isEmpty()) || (mainwindow_visible) ) {
106
#ifdef USE_SYSTEM_TRAY
107
if ( (!showTrayAct->isOn()) || (!initial_files.empty()) ||
108
(mainwindow_visible) )
96
113
BaseGui::firstShow();
100
117
void BaseGuiPlus::closeEvent( QCloseEvent * e ) {
101
#if QT_VERSION >= 0x040200
118
qDebug("BaseGuiPlus::closeEvent");
123
void BaseGuiPlus::closeWindow() {
124
qDebug("BaseGuiPlus::closeWindow");
125
#ifdef USE_SYSTEM_TRAY
102
126
if (tray->isVisible()) {
104
129
showAll(false); // Hide windows
105
130
if (core->state == PLAYING) core->stop();
106
tray->showMessage( "SMPlayer",
107
tr("SMPlayer is still running here"),
108
QSystemTrayIcon::Information, 3000 );
131
#if QT_VERSION >= 0x040200
132
if (pref->balloon_count > 0) {
133
tray->showMessage( "SMPlayer",
134
tr("SMPlayer is still running here"),
135
QSystemTrayIcon::Information, 3000 );
136
pref->balloon_count--;
110
BaseGui::closeEvent(e);
140
BaseGui::closeWindow();
114
BaseGui::closeEvent(e);
144
BaseGui::closeWindow();
148
void BaseGuiPlus::quit() {
149
qDebug("BaseGuiPlus::quit");
150
BaseGui::closeWindow();
118
153
void BaseGuiPlus::languageChange() {
119
154
BaseGui::languageChange();
121
#if QT_VERSION >= 0x040200
156
#ifdef USE_SYSTEM_TRAY
157
quitAct->change( Images::icon("exit"), tr("&Quit") );
122
158
showTrayAct->change( tr("S&how icon in system tray") );
123
159
context_menu->changeItem( recents_menu_id, tr("&Recent files") );
124
160
updateShowAllAct();
128
164
void BaseGuiPlus::updateShowAllAct() {
129
#if QT_VERSION >= 0x040200
165
#ifdef USE_SYSTEM_TRAY
131
167
showAllAct->change( tr("&Hide") );
133
169
showAllAct->change( tr("&Restore") );
137
173
void BaseGuiPlus::saveConfig() {
138
174
qDebug("BaseGuiPlus::saveConfig");
140
#if QT_VERSION >= 0x040200
176
#ifdef USE_SYSTEM_TRAY
142
178
QSettings * set = settings;
182
218
if (reason == QSystemTrayIcon::Trigger) {
222
if (reason == QSystemTrayIcon::MiddleClick) {
188
228
void BaseGuiPlus::toggleShowAll() {
189
#if QT_VERSION >= 0x040200
229
#ifdef USE_SYSTEM_TRAY
190
230
showAll( !isVisible() );
194
234
void BaseGuiPlus::showAll(bool b) {
195
#if QT_VERSION >= 0x040200
235
#ifdef USE_SYSTEM_TRAY
198
238
mainwindow_pos = pos();
227
267
updateShowAllAct();
231
271
void BaseGuiPlus::resizeWindow(int w, int h) {
232
272
qDebug("BaseGuiPlus::resizeWindow: %d, %d", w, h);
234
#if QT_VERSION >= 0x040200
274
#ifdef USE_SYSTEM_TRAY
235
275
if ( (tray->isVisible()) && (!isVisible()) ) showAll(true);
238
278
BaseGui::resizeWindow(w, h );
241
281
void BaseGuiPlus::updateMediaInfo() {
242
282
qDebug("BaseGuiPlus::updateMediaInfo");
243
283
BaseGui::updateMediaInfo();
244
#if QT_VERSION >= 0x040200
285
#ifdef USE_SYSTEM_TRAY
245
286
tray->setToolTip( caption() );
290
void BaseGuiPlus::setWindowCaption(const QString & title) {
291
#ifdef USE_SYSTEM_TRAY
292
tray->setToolTip( title );
294
BaseGui::setWindowCaption( title );