diff --git a/src/breakcontrol.cpp b/src/breakcontrol.cpp index aa8a1e1..8fd32e8 100644 --- a/src/breakcontrol.cpp +++ b/src/breakcontrol.cpp @@ -1,134 +1,133 @@ /* Copyright (C) 2009-2010 Tom Albers Copyright (C) 2010 Juan Luis Baptiste 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 "breakcontrol.h" #include #include #include #include #include #include #include #include #include #include -#include #include BreakControl::BreakControl( QWidget* parent, Qt::WindowType type ) : QWidget( parent, type ) { m_vbox = new QVBoxLayout; m_textLabel = new QLabel( this ); m_textLabel->setAlignment( Qt::AlignHCenter ); QWidget* hbox = new QWidget( this ); QHBoxLayout *hboxHBoxLayout = new QHBoxLayout(hbox); hboxHBoxLayout->setContentsMargins(0, 0, 0, 0); hboxHBoxLayout->setSpacing( 25 ); m_skipButton = new QPushButton( i18n( "Skip Break" ), hbox ); hboxHBoxLayout->addWidget(m_skipButton); QSize sizeSkip( m_skipButton->size() ); m_skipButton->setIcon( QIcon::fromTheme( "dialog-cancel" ) ); m_skipButton->setFixedHeight( sizeSkip.height() ); connect(m_skipButton, &QPushButton::clicked, this, &BreakControl::skip); m_postponeButton = new QPushButton( i18n( "Postpone Break" ), hbox ); hboxHBoxLayout->addWidget(m_postponeButton); QSize sizePostpone(m_postponeButton->size()); m_postponeButton->setIcon(QIcon::fromTheme("go-next")); m_postponeButton->setFixedHeight(sizePostpone.height()); connect(m_postponeButton, &QPushButton::clicked, this, &BreakControl::postpone); m_lockButton = new QPushButton( i18n( "Lock Screen" ), hbox ); hboxHBoxLayout->addWidget(m_lockButton); QSize sizeLock( m_skipButton->size() ); m_lockButton->setFixedHeight( sizeLock.height() ); m_lockButton->setIcon( QIcon::fromTheme( "system-lock-screen" ) ); connect(m_lockButton, &QPushButton::clicked, this, &BreakControl::slotLock); m_vbox->addWidget( m_textLabel ); m_vbox->addWidget( hbox ); setLayout( m_vbox ); connect( qApp, &QGuiApplication::screenAdded, this, &BreakControl::slotCenterIt ); connect( qApp, &QGuiApplication::screenRemoved, this, &BreakControl::slotCenterIt ); slotCenterIt(); } void BreakControl::slotCenterIt() { const QRect r( QGuiApplication::primaryScreen()->geometry() ); const QPoint center( r.width() / 2 - sizeHint().width() / 2, r.y() ); move( center ); } void BreakControl::slotLock() { emit lock(); } void BreakControl::setText( const QString& text ) { m_textLabel->setText( text ); } void BreakControl::showMinimize( bool show ) { m_skipButton->setVisible( show ); } void BreakControl::showLock( bool show ) { m_lockButton->setVisible( show ); } void BreakControl::showPostpone( bool show ) { m_postponeButton->setVisible( show ); } void BreakControl::paintEvent( QPaintEvent *event ) { if ( event->type() == QEvent::Paint ) { int margin = 3; QPainterPath box; box.moveTo( rect().topLeft() ); box.lineTo( rect().bottomLeft() ); box.lineTo( rect().bottomRight() ); box.lineTo( rect().topRight() ); box.closeSubpath(); QColor highlight = palette().highlight().color(); highlight.setAlphaF( 0.7 ); QPen pen( highlight ); pen.setWidth( margin ); QPainter painter( this ); painter.setPen( pen ); painter.drawPath( box ); } } diff --git a/src/rsidock.cpp b/src/rsidock.cpp index 9de9520..3c50132 100644 --- a/src/rsidock.cpp +++ b/src/rsidock.cpp @@ -1,240 +1,239 @@ /* Copyright (C) 2005-2006 Tom Albers Copyright (C) 2011 Aurélien Gâteau Orginal copied from ksynaptics: Copyright (C) 2004 Nadeem Hasan 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 "rsidock.h" #include "setup.h" #include "rsistatwidget.h" #include "rsistats.h" #include #include #include #include #include -#include #include #include #include #include #include #include #include #include #include #include #include template static QAction *doAddAction(QMenu *menu, const QString &text, Object *receiver, Func func) { QAction *action = menu->addAction(text); QObject::connect(action, &QAction::triggered, receiver, func); return action; } template static QAction *doAddAction(QMenu *menu, const QIcon &icon, const QString &text, Object *receiver, Func func) { QAction *action = doAddAction(menu, text, receiver, func); action->setIcon(icon); return action; } RSIDock::RSIDock( QObject *parent ) : KStatusNotifierItem( parent ), m_suspended( false ) , m_statsDialog( 0 ), m_statsWidget( 0 ) { setCategory(ApplicationStatus); setStatus(Active); const KAboutData &aboutData = KAboutData::applicationData(); setTitle( aboutData.displayName() ); setToolTipTitle( aboutData.displayName() ); m_help = new KHelpMenu( 0, aboutData ); QMenu* menu = contextMenu(); doAddAction( menu, QIcon::fromTheme( "kde" ), i18n( "About &KDE" ), m_help, &KHelpMenu::aboutKDE ); doAddAction( menu, i18n( "&About RSIBreak" ), m_help, &KHelpMenu::aboutApplication ); doAddAction( menu, QIcon::fromTheme( "help-contents" ), i18n( "RSIBreak &Handbook" ), m_help, &KHelpMenu::appHelpActivated ); menu->addSeparator(); doAddAction( menu, QIcon::fromTheme( "tools-report-bug" ), i18n( "&Report Bug..." ), m_help, &KHelpMenu::reportBug ); doAddAction( menu, i18n( "Switch application &language..." ), m_help, &KHelpMenu::switchApplicationLanguage ); menu->addSeparator(); m_suspendItem = doAddAction(menu, QIcon::fromTheme( "media-playback-pause" ), i18n( "&Suspend RSIBreak" ), this, &RSIDock::slotToggleSuspend ); doAddAction(menu, QIcon::fromTheme( "view-statistics" ), i18n( "&Usage Statistics" ), this, &RSIDock::slotShowStatistics ); doAddAction(menu, QIcon::fromTheme( "preferences-desktop-notification" ), i18n( "Configure &Notifications..." ), this, &RSIDock::slotConfigureNotifications ); doAddAction(menu, QIcon::fromTheme( "configure" ), i18n( "&Configure RSIBreak..." ), this, &RSIDock::slotConfigure ); connect(this, &RSIDock::activateRequested, this, &RSIDock::slotShowStatistics); } RSIDock::~RSIDock() { delete m_help; delete m_statsWidget; delete m_statsDialog; m_statsWidget = 0; } void RSIDock::doResume() { if ( m_suspended ) slotToggleSuspend(); } void RSIDock::doSuspend() { if ( !m_suspended ) slotToggleSuspend(); } void RSIDock::slotConfigureNotifications() { KNotifyConfigWidget::configure( 0 ); } void RSIDock::slotConfigure() { // don't think it is needed, because setup is not accessed after the // exec call, but better safe than crash. QPointer setup = new Setup( 0 ); emit dialogEntered(); if ( setup->exec() == QDialog::Accepted ) emit configChanged( !m_suspended ); delete setup; if ( !m_suspended ) emit dialogLeft(); } void RSIDock::slotToggleSuspend() { if ( m_suspended ) { emit suspend( false ); setIconByName( "rsibreak0" ); m_suspendItem->setIcon( QIcon::fromTheme( "media-playback-pause" ) ); m_suspendItem->setText( i18n( "&Suspend RSIBreak" ) ); } else { emit suspend( true ); setIconByName( "rsibreakx" ); m_suspendItem->setIcon( QIcon::fromTheme( "media-playback-start" ) ); m_suspendItem->setText( i18n( "&Resume RSIBreak" ) ); } m_suspended = !m_suspended; } void RSIDock::slotShowStatistics() { if ( !m_statsDialog ) { m_statsDialog = new QDialog( 0 ); m_statsDialog->setWindowTitle( i18n( "Usage Statistics" ) ); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); QVBoxLayout *mainLayout = new QVBoxLayout; m_statsDialog->setLayout(mainLayout); QPushButton *user1Button = new QPushButton; buttonBox->addButton(user1Button, QDialogButtonBox::ActionRole); connect(buttonBox, &QDialogButtonBox::accepted, m_statsDialog, &QDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, m_statsDialog, &QDialog::reject); user1Button->setText(i18n( "Reset" )); m_statsWidget = new RSIStatWidget( m_statsDialog ); connect(user1Button, &QPushButton::clicked, this, &RSIDock::slotResetStats); mainLayout->addWidget(m_statsWidget); mainLayout->addWidget(buttonBox); } if ( m_statsDialog->isVisible() && KWindowInfo(m_statsDialog->winId(), NET::WMDesktop ).isOnCurrentDesktop() ) { m_statsDialog->hide(); } else { m_statsDialog->show(); if ( !m_statsDialog->isActiveWindow() ) KWindowSystem::forceActiveWindow( m_statsDialog->winId() ); m_statsDialog->raise(); } } void RSIDock::slotResetStats() { int i = KMessageBox::warningContinueCancel( 0, i18n( "This will reset all statistics to zero. " "Is that what you want?" ), i18n( "Reset the statistics" ), KGuiItem( i18n( "Reset" ) ), KStandardGuiItem::cancel(), "resetStatistics" ); if ( i == KMessageBox::Continue ) RSIGlobals::instance()->stats()->reset(); } static QString colorizedText( const QString& text, const QColor& color ) { return QString(" %2") .arg(color.name(), text.toHtmlEscaped()); } void RSIDock::setCounters( int tiny_left, int big_left ) { if ( m_suspended ) setToolTipSubTitle( i18n( "Suspended" ) ); else { QColor tinyColor = RSIGlobals::instance()->getTinyBreakColor( tiny_left ); RSIGlobals::instance()->stats()->setColor( LAST_TINY_BREAK, tinyColor ); QColor bigColor = RSIGlobals::instance()-> getBigBreakColor( big_left ); RSIGlobals::instance()->stats()->setColor( LAST_BIG_BREAK, bigColor ); // Only add the line for the tiny break when there is not // a big break planned at the same time. QStringList lines; if ( tiny_left != big_left ) { QString formattedText = RSIGlobals::instance()->formatSeconds( tiny_left ); if ( !formattedText.isNull() ) { lines << colorizedText( i18n( "%1 remaining until next short break", formattedText ), tinyColor ); } } // do the same for the big break if ( big_left > 0 ) lines << colorizedText( i18n( "%1 remaining until next long break", RSIGlobals::instance()->formatSeconds( big_left ) ), bigColor ); setToolTipSubTitle(lines.join("
")); } } diff --git a/src/rsirelaxpopup.cpp b/src/rsirelaxpopup.cpp index df5a1f8..fd78950 100644 --- a/src/rsirelaxpopup.cpp +++ b/src/rsirelaxpopup.cpp @@ -1,177 +1,176 @@ /* Copyright (C) 2005 Bram Schoenmakers Copyright (C) 2005-2007,2010 Tom Albers Copyright (C) 2010 Juan Luis Baptiste 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 "rsirelaxpopup.h" #include #include #include #include #include #include #include #include #include -#include #include #include RSIRelaxPopup::RSIRelaxPopup( QWidget *parent ) : QObject( parent ) , m_wasShown( false ) { m_popup = new PassivePopup( parent ); QWidget *vbox = new QWidget( m_popup ); QVBoxLayout *vboxVBoxLayout = new QVBoxLayout(vbox); vboxVBoxLayout->setContentsMargins(0, 0, 0, 0); vboxVBoxLayout->setSpacing( 5 ); m_message = new QLabel( vbox ); vboxVBoxLayout->addWidget(m_message); QWidget *hbox = new QWidget( vbox ); QHBoxLayout *hboxHBoxLayout = new QHBoxLayout(hbox); hboxHBoxLayout->setContentsMargins(0, 0, 0, 0); vboxVBoxLayout->addWidget(hbox); hboxHBoxLayout->setSpacing( 15 ); m_progress = new QProgressBar( hbox ); hboxHBoxLayout->addWidget(m_progress); m_progress->setFormat( "%v" ); m_progress->setRange( 0, 0 ); m_skipbutton = new QPushButton( QIcon::fromTheme( "dialog-cancel" ), i18n( "Skip Break" ), hbox ); hboxHBoxLayout->addWidget(m_skipbutton); m_skipbutton->setToolTip( i18n( "Skip this break" ) ); connect(m_skipbutton, &QPushButton::clicked, this, &RSIRelaxPopup::skip); m_postponebutton = new QPushButton( QIcon::fromTheme( "go-next" ), i18n( "Postpone Break" ), hbox ); hboxHBoxLayout->addWidget(m_postponebutton); m_postponebutton->setToolTip( i18n( "Postpone this break" ) ); connect(m_postponebutton, &QPushButton::clicked, this, &RSIRelaxPopup::postpone); m_lockbutton = new QPushButton( QIcon::fromTheme( "system-lock-screen" ), i18n( "Lock Screen" ), hbox ); hboxHBoxLayout->addWidget(m_lockbutton); m_lockbutton->setToolTip( i18n( "Lock the session" ) ); connect(m_lockbutton, &QPushButton::clicked, this, &RSIRelaxPopup::lock); m_popup->setTimeout( 0 ); // no auto close m_popup->setView( vbox ); readSettings(); } RSIRelaxPopup::~RSIRelaxPopup() {} void RSIRelaxPopup::relax( int n, bool bigBreakNext ) { /* Counts how many times a request for relax resets due to detected activity. */ static int resetcount = 0; /* If n increases compared to the last call, we want a new request for a relax moment. */ if ( n >= m_progress->value() ) { m_progress->setRange( 0, n ); resetcount += 1; if ( n > m_progress->value() ) flash(); else if ( resetcount % 4 == 0 ) // flash regularly when the user keeps working flash(); } if ( n > 0 ) { QString text = i18n( "Please relax for %1", KFormat().formatSpelloutDuration( n * 1000 ) ); if ( bigBreakNext ) text.append( '\n' + i18n( "Note: next break is a big break" ) ); m_message->setText( text ); m_progress->setValue( n ); if ( resetcount == 1 ) m_popup->show(); } else { m_popup->setVisible( false ); resetcount = 0; m_wasShown = false; } } void RSIRelaxPopup::flash() { if ( !m_useFlash ) return; QTimer::singleShot( 500, this, &RSIRelaxPopup::unflash ); QPalette normal; normal.setColor( QPalette::Inactive, QPalette::WindowText, KColorScheme( QPalette::Active, KColorScheme::Selection ).background().color() ); normal.setColor( QPalette::Inactive, QPalette::Window, KColorScheme( QPalette::Active, KColorScheme::Selection ).foreground().color() ); m_popup->setPalette( normal ); } void RSIRelaxPopup::unflash() { QPalette normal; m_popup->setPalette( normal ); } void RSIRelaxPopup::slotReadConfig() { readSettings(); } void RSIRelaxPopup::readSettings() { KConfigGroup config = KSharedConfig::openConfig()->group( "Popup Settings" ); m_useFlash = config.readEntry( "UseFlash", true ); } void RSIRelaxPopup::setSkipButtonHidden( bool b ) { m_skipbutton->setHidden( b ); } void RSIRelaxPopup::setLockButtonHidden( bool b ) { m_lockbutton->setHidden( b ); } void RSIRelaxPopup::setPostponeButtonHidden( bool b ) { m_postponebutton->setHidden( b ); } void RSIRelaxPopup::setSuspended( bool suspended ) { if ( suspended ) { m_wasShown = m_popup->isVisible(); m_popup->hide(); } else if (m_wasShown) { m_popup->show(); } } diff --git a/src/rsiwidget.cpp b/src/rsiwidget.cpp index 5812a89..631be62 100644 --- a/src/rsiwidget.cpp +++ b/src/rsiwidget.cpp @@ -1,275 +1,274 @@ /* Copyright (C) 2005-2006,2009-2010 Tom Albers Copyright (C) 2006 Bram Schoenmakers Copyright (C) 2010 Juan Luis Baptiste 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 "rsiwidget.h" #include "rsiwidgetadaptor.h" #include "grayeffect.h" #include "popupeffect.h" #include "plasmaeffect.h" #include "slideshoweffect.h" #include "rsitimer.h" #include "rsidock.h" #include "rsirelaxpopup.h" #include "rsiglobals.h" #include #include #include #include #include #include -#include #include #include #include #include #include #include #include #include RSIObject::RSIObject( QWidget *parent ) : QObject( parent ) , m_timer(nullptr), m_effect( 0 ) , m_useImages( false ), m_usePlasma( false ), m_usePlasmaRO( false ) { // Keep these 2 lines _above_ the messagebox, so the text actually is right. m_tray = new RSIDock( this ); m_tray->setIconByName( "rsibreak0" ); new RsiwidgetAdaptor( this ); QDBusConnection dbus = QDBusConnection::sessionBus(); dbus.registerObject( "/rsibreak", this ); m_relaxpopup = new RSIRelaxPopup( 0 ); connect(m_relaxpopup, &RSIRelaxPopup::lock, this, &RSIObject::slotLock); connect(m_tray, &RSIDock::configChanged, this, &RSIObject::readConfig); connect(m_tray, &RSIDock::configChanged, RSIGlobals::instance(), &RSIGlobals::slotReadConfig ); connect(m_tray, &RSIDock::configChanged, m_relaxpopup, &RSIRelaxPopup::slotReadConfig); connect(m_tray, &RSIDock::suspend, m_relaxpopup, &RSIRelaxPopup::setSuspended); readConfig(); setIcon( 0 ); QTimer::singleShot( 2000, this, &RSIObject::slotWelcome ); } RSIObject::~RSIObject() { delete m_effect; delete RSIGlobals::instance(); if (m_timer != nullptr) { m_timer->quit(); m_timer->wait(); delete m_timer; } } void RSIObject::slotWelcome() { if ( KMessageBox::shouldBeShownContinue( "dont_show_welcome_again_for_001" ) ) { KMessageBox::information( 0, i18n( "

Welcome to RSIBreak

\n

" "In your tray you can now see RSIBreak.

\n" ) + i18n( "

When you right-click on that you will see a menu, from which " "you can go to the configuration for example.

\n

When you want to " "know when the next break is, hover over the icon.

\n

Use RSIBreak " "wisely.

" ), i18n( "Welcome" ), "dont_show_welcome_again_for_001" ); } } void RSIObject::minimize() { m_effect->deactivate(); } void RSIObject::maximize() { m_effect->activate(); } void RSIObject::slotLock() { m_effect->deactivate(); m_timer->slotLock(); QDBusInterface lock( "org.freedesktop.ScreenSaver", "/ScreenSaver", "org.freedesktop.ScreenSaver" ); lock.call( "Lock" ); } void RSIObject::setCounters( int timeleft ) { if ( timeleft > 0 ) { m_effect->setLabel( KFormat().formatSpelloutDuration( timeleft * 1000 ) ); } else if ( m_timer->isSuspended() ) { m_effect->setLabel( i18n( "Suspended" ) ); } else { m_effect->setLabel( QString() ); } } void RSIObject::updateIdleAvg( double idleAvg ) { if ( idleAvg == 0.0 ) setIcon( 0 ); else if ( idleAvg > 0 && idleAvg < 30 ) setIcon( 1 ); else if ( idleAvg >= 30 && idleAvg < 60 ) setIcon( 2 ); else if ( idleAvg >= 60 && idleAvg < 90 ) setIcon( 3 ); else setIcon( 4 ); } void RSIObject::setIcon( int level ) { QString newIcon = "rsibreak" + ( m_timer->isSuspended() ? QString( "x" ) : QString::number( level ) ); if ( newIcon != m_currentIcon ) { m_tray->setIconByName( newIcon ); m_tray->setToolTipIconByName( newIcon ); m_currentIcon = newIcon; } } // ------------------- Popup for skipping break ------------- // void RSIObject::tinyBreakSkipped() { m_notificator.onShortTimerReset(); } void RSIObject::bigBreakSkipped() { m_notificator.onTimersReset(); } //--------------------------- CONFIG ----------------------------// void RSIObject::configureTimer() { if (m_timer != nullptr) { m_timer->updateConfig(); return; } m_timer = new RSITimer(this); connect(m_timer, &RSITimer::breakNow, this, &RSIObject::maximize, Qt::QueuedConnection ); connect(m_timer, &RSITimer::updateWidget, this, &RSIObject::setCounters, Qt::QueuedConnection ); connect(m_timer, &RSITimer::updateToolTip, m_tray, &RSIDock::setCounters, Qt::QueuedConnection ); connect(m_timer, &RSITimer::updateIdleAvg, this, &RSIObject::updateIdleAvg, Qt::QueuedConnection ); connect(m_timer, &RSITimer::minimize, this, &RSIObject::minimize, Qt::QueuedConnection ); connect(m_timer, &RSITimer::relax, m_relaxpopup, &RSIRelaxPopup::relax, Qt::QueuedConnection ); connect(m_timer, &RSITimer::tinyBreakSkipped, this, &RSIObject::tinyBreakSkipped, Qt::QueuedConnection ); connect(m_timer, &RSITimer::bigBreakSkipped, this, &RSIObject::bigBreakSkipped, Qt::QueuedConnection ); connect(m_timer, &RSITimer::startLongBreak, &m_notificator, &Notificator::onStartLongBreak ); connect(m_timer, &RSITimer::endLongBreak, &m_notificator, &Notificator::onEndLongBreak ); connect(m_timer, &RSITimer::startShortBreak, &m_notificator, &Notificator::onStartShortBreak ); connect(m_timer, &RSITimer::endShortBreak, &m_notificator, &Notificator::onEndShortBreak ); connect(m_tray, &RSIDock::configChanged, m_timer, &RSITimer::updateConfig); connect(m_tray, &RSIDock::dialogEntered, m_timer, &RSITimer::slotStop); connect(m_tray, &RSIDock::dialogLeft, m_timer, &RSITimer::slotStart); connect(m_tray, &RSIDock::suspend, m_timer, &RSITimer::slotSuspended); connect(m_relaxpopup, &RSIRelaxPopup::skip, m_timer, &RSITimer::skipBreak); connect(m_relaxpopup, &RSIRelaxPopup::postpone, m_timer, &RSITimer::postponeBreak); m_timer->start(); } void RSIObject::readConfig() { KConfigGroup config = KSharedConfig::openConfig()->group( "General Settings" ); m_relaxpopup->setSkipButtonHidden( config.readEntry( "HideMinimizeButton", false ) ); m_relaxpopup->setLockButtonHidden( config.readEntry( "HideLockButton", false ) ); m_relaxpopup->setPostponeButtonHidden( config.readEntry( "HidePostponeButton", false ) ); m_usePlasma = config.readEntry( "UsePlasma", false ); m_usePlasmaRO = config.readEntry( "UsePlasmaReadOnly", false ); m_useImages = config.readEntry( "ShowImages", false ); int slideInterval = config.readEntry( "SlideInterval", 10 ); bool recursive = config.readEntry( "SearchRecursiveCheck", false ); bool showSmallImages = config.readEntry( "ShowSmallImagesCheck", true ); const bool expandImageToFullScreen = config.readEntry( "ExpandImageToFullScreen", true ); QString path = config.readEntry( "ImageFolder" ); configureTimer(); int effect = config.readEntry( "Effect", 0 ); delete m_effect; switch ( effect ) { case Plasma: { m_effect = new PlasmaEffect( 0 ); m_effect->setReadOnly( m_usePlasmaRO ); break; } case SlideShow: { SlideEffect* slide = new SlideEffect( 0 ); slide->reset( path, recursive, showSmallImages, expandImageToFullScreen, slideInterval ); if ( slide->hasImages() ) m_effect = slide; else { delete slide; m_effect = new GrayEffect( 0 ); } break; } case Popup: { PopupEffect* effect = new PopupEffect( 0 ); m_effect = effect; break; } case SimpleGray: default: { GrayEffect* effect = new GrayEffect( 0 ); effect->setLevel( config.readEntry( "Graylevel", 80 ) ); m_effect = effect; break; } } connect(m_effect, &BreakBase::skip, m_timer, &RSITimer::skipBreak); connect(m_effect, &BreakBase::lock, this, &RSIObject::slotLock); connect(m_effect, &BreakBase::postpone, m_timer, &RSITimer::postponeBreak); m_effect->showMinimize( !config.readEntry( "HideMinimizeButton", false ) ); m_effect->showLock( !config.readEntry( "HideLockButton", false ) ); m_effect->showPostpone( !config.readEntry( "HidePostponeButton", false ) ); m_effect->disableShortcut( config.readEntry( "DisableAccel", false ) ); } void RSIObject::resume() { m_tray->doResume(); } void RSIObject::suspend() { m_tray->doSuspend(); } diff --git a/src/setup.cpp b/src/setup.cpp index 5a4bdad..8b4f6fd 100644 --- a/src/setup.cpp +++ b/src/setup.cpp @@ -1,96 +1,95 @@ /* ============================================================ * Copyright 2005-2007,2010 by Tom Albers * * 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, 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 "setup.h" // Qt includes. #include // KDE includes. #include #include #include -#include #include // Local includes. #include "setupgeneral.h" #include "setuptiming.h" #include "setupmaximized.h" #include "setupnotifications.h" class SetupPriv { public: SetupGeneral *generalPage; SetupTiming *timingPage; SetupMaximized *maximizedPage; SetupNotifications *notificationsPage; }; Setup::Setup( QWidget* parent ) : KPageDialog( parent ) { setFaceType( List ); d = new SetupPriv; d->generalPage = new SetupGeneral( this ); KPageWidgetItem* page1 = addPage( d->generalPage, i18n( "General Settings" ) ); page1->setIcon( QIcon::fromTheme( "configure" ) ); d->timingPage = new SetupTiming( this ); KPageWidgetItem* page2 = addPage( d->timingPage, i18n( "Timings" ) ); page2->setIcon( QIcon::fromTheme( "timings" ) ); d->maximizedPage = new SetupMaximized( this ); KPageWidgetItem* page3 = addPage( d->maximizedPage, i18n( "During Breaks" ) ); page3->setIcon( QIcon::fromTheme( "duringbreaks" ) ); // krazy:exclude=iconnames d->notificationsPage = new SetupNotifications( this ); KPageWidgetItem* page4 = addPage( d->notificationsPage, i18n( "Actions" ) ); page4->setIcon( QIcon::fromTheme( "configure" ) ); // krazy:exclude=iconnames connect(this, &Setup::accepted, this, &Setup::slotOkClicked); connect(d->generalPage, &SetupGeneral::useIdleTimerChanged, d->maximizedPage, &SetupMaximized::slotSetUseIdleTimer); d->maximizedPage->slotSetUseIdleTimer(d->generalPage->useIdleTimer()); connect(d->generalPage, &SetupGeneral::useIdleTimerChanged, d->timingPage, &SetupTiming::slotSetUseIdleTimer); d->timingPage->slotSetUseIdleTimer(d->generalPage->useIdleTimer()); KConfigGroup config = KSharedConfig::openConfig()->group( "SetupDimensions" ); KWindowConfig::restoreWindowSize( windowHandle(), config ); show(); } Setup::~Setup() { KConfigGroup config = KSharedConfig::openConfig()->group( "SetupDimensions" ); KWindowConfig::saveWindowSize( windowHandle(), config ); delete d; } void Setup::slotOkClicked() { d->generalPage->applySettings(); d->timingPage->applySettings(); d->maximizedPage->applySettings(); d->notificationsPage->save(); close(); }