diff --git a/.astylerc b/.astylerc index 7bf72ba..cd28d81 100644 --- a/.astylerc +++ b/.astylerc @@ -1,30 +1,38 @@ #BracketStyleOptions - --style=attach - --keep-one-line-blocks - --keep-one-line-statements + --style=stroustrup + --keep-one-line-blocks + --keep-one-line-statements #TabOptions - --indent=force-tab=4 +# --indent=force-tab=4 + --indent=spaces=4 #BracketModifyOptions - --attach-namespaces - --attach-inlines + --attach-namespaces + --attach-inlines + +#FormattingOptions + --convert-tabs + --max-code-length=200 + --keep-one-line-blocks + --keep-one-line-statements + --close-templates #IndentationOptions - --indent-modifiers - --indent-switches -# --indent-preproc-block - --indent-preproc-define - --indent-col1-comments - --min-conditional-indent=2 - --max-instatement-indent=40#default40 - --break-blocks - --pad-oper - --pad-paren-in - --pad-header - --fill-empty-lines - --align-pointer=name - --remove-brackets - --keep-one-line-blocks - --keep-one-line-statements - --close-templates + --indent-switches + --indent-preproc-block + --indent-preproc-define + --min-conditional-indent=1 + --max-instatement-indent=40 + +#PaddingOptions + --break-blocks + --pad-oper + --unpad-paren + --pad-header + --align-pointer=name + --align-reference=name + +#Others + --preserve-date + --verbose diff --git a/engine/configdialog.cpp b/engine/configdialog.cpp index 49186dd..887a9b9 100644 --- a/engine/configdialog.cpp +++ b/engine/configdialog.cpp @@ -26,62 +26,66 @@ #include "generalwidget.h" #include "playbarsettings.h" -ConfigDialog::ConfigDialog( KActionCollection *collection , QWidget *parent ) - : KConfigDialog( parent, QLatin1String( "PlayBar Settings" ), PlayBarSettings::self() ), - m_generalPage( new GeneralWidget( this ) ) { - setWindowTitle( i18n( "Configure PlayBar" ) ); - m_shortcutsPage = new KShortcutsEditor( collection, this, KShortcutsEditor::GlobalAction ); - setStandardButtons( QDialogButtonBox::Apply | QDialogButtonBox::Ok | QDialogButtonBox::Cancel ); - - addPage( m_generalPage - , i18nc( "General config", "General" ) - , "applications-multimedia" - , i18nc( "General config", "General" ) ); - - addPage( m_shortcutsPage - , i18nc( "Shortcuts config", "Shortcuts" ) - , "configure-shortcuts" - , i18n( "Shortcuts Configuration" ) ); - - connect( this, SIGNAL( accepted() ), this, SLOT( updateSettings() ) ); - - QPushButton *apply = this->button( QDialogButtonBox::Apply ); - connect( apply, SIGNAL( clicked() ), this, SLOT( updateSettings() ) ); - - connect( m_generalPage, SIGNAL( shadowColorChanged( const QColor & ) ), - this, SLOT( updateColorSettings() ) ); - - connect( this, SIGNAL( finished( int ) ), this, SLOT( deleteLater() ) ); +ConfigDialog::ConfigDialog(KActionCollection *collection , QWidget *parent) + : KConfigDialog(parent, QLatin1String("PlayBar Settings"), PlayBarSettings::self()), + m_generalPage(new GeneralWidget(this)) +{ + setWindowTitle(i18n("Configure PlayBar")); + m_shortcutsPage = new KShortcutsEditor(collection, this, KShortcutsEditor::GlobalAction); + setStandardButtons(QDialogButtonBox::Apply | QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + + addPage(m_generalPage + , i18nc("General config", "General") + , "applications-multimedia" + , i18nc("General config", "General")); + + addPage(m_shortcutsPage + , i18nc("Shortcuts config", "Shortcuts") + , "configure-shortcuts" + , i18n("Shortcuts Configuration")); + + connect(this, SIGNAL(accepted()), this, SLOT(updateSettings())); + + QPushButton *apply = this->button(QDialogButtonBox::Apply); + connect(apply, SIGNAL(clicked()), this, SLOT(updateSettings())); + + connect(m_generalPage, SIGNAL(shadowColorChanged(const QColor &)), + this, SLOT(updateColorSettings())); + + connect(this, SIGNAL(finished(int)), this, SLOT(deleteLater())); } -ConfigDialog::~ConfigDialog() { - delete m_generalPage; - delete m_shortcutsPage; - qDebug() << metaObject()->className() << "deleted"; +ConfigDialog::~ConfigDialog() +{ + delete m_generalPage; + delete m_shortcutsPage; + qDebug() << metaObject()->className() << "deleted"; } -void ConfigDialog::updateColorSettings() { - PlayBarSettings *config = PlayBarSettings::self(); - - config->setShadowColor( m_generalPage->shadowColor() ); - config->save(); +void ConfigDialog::updateColorSettings() +{ + PlayBarSettings *config = PlayBarSettings::self(); + + config->setShadowColor(m_generalPage->shadowColor()); + config->save(); } -void ConfigDialog::updateSettings() { - // User clicks Ok or Apply button in configuration dialog - m_shortcutsPage->save(); - auto *config = PlayBarSettings::self(); - - config->setCompactStyle ( m_generalPage->compactStyle() ); - config->setShowStop ( m_generalPage->showStop() ); - config->setShowSeekSlider ( m_generalPage->showSeekSlider() ); - config->setShowVolumeSlider ( m_generalPage->showVolumeSlider() ); - config->setBackgroundHint ( m_generalPage->backgroundHint() ); - config->setNoBackground ( m_generalPage->noBackground() ); - config->setNormal ( m_generalPage->normal() ); - config->setTranslucent ( m_generalPage->translucent() ); - config->setShadowColor ( m_generalPage->shadowColor() ); - config->save(); - qDebug() << metaObject()->className() << "config saved"; +void ConfigDialog::updateSettings() +{ + // User clicks Ok or Apply button in configuration dialog + m_shortcutsPage->save(); + auto *config = PlayBarSettings::self(); + + config->setCompactStyle(m_generalPage->compactStyle()); + config->setShowStop(m_generalPage->showStop()); + config->setShowSeekSlider(m_generalPage->showSeekSlider()); + config->setShowVolumeSlider(m_generalPage->showVolumeSlider()); + config->setBackgroundHint(m_generalPage->backgroundHint()); + config->setNoBackground(m_generalPage->noBackground()); + config->setNormal(m_generalPage->normal()); + config->setTranslucent(m_generalPage->translucent()); + config->setShadowColor(m_generalPage->shadowColor()); + config->save(); + qDebug() << metaObject()->className() << "config saved"; } // kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/engine/configdialog.h b/engine/configdialog.h index 14325ba..dd351fa 100644 --- a/engine/configdialog.h +++ b/engine/configdialog.h @@ -30,26 +30,26 @@ #include "generalwidget.h" class ConfigDialog : public KConfigDialog { - Q_OBJECT - public: - ConfigDialog ( KActionCollection *collection, QWidget *parent = nullptr ); - - virtual ~ConfigDialog(); - - protected Q_SLOTS: - void updateSettings(); - void updateColorSettings(); - - private: - KSharedConfigPtr config() const; - - private: - GeneralWidget *m_generalPage; - KShortcutsEditor *m_shortcutsPage; - - public: - static constexpr const char *CONFIG_NAME { "PlayBar Settings" }; - + Q_OBJECT +public: + ConfigDialog(KActionCollection *collection, QWidget *parent = nullptr); + + virtual ~ConfigDialog(); + +protected Q_SLOTS: + void updateSettings(); + void updateColorSettings(); + +private: + KSharedConfigPtr config() const; + +private: + GeneralWidget *m_generalPage; + KShortcutsEditor *m_shortcutsPage; + +public: + static constexpr const char *CONFIG_NAME { "PlayBar Settings" }; + }; #endif // CONFIGDIALOG_H diff --git a/engine/generalwidget.cpp b/engine/generalwidget.cpp index e232297..4d50449 100644 --- a/engine/generalwidget.cpp +++ b/engine/generalwidget.cpp @@ -19,11 +19,12 @@ #include "generalwidget.h" -GeneralWidget::GeneralWidget( QWidget *parent ) - : QWidget( parent ) { - m_ui.setupUi( this ); - connect( m_ui.kcfg_ShadowColor, SIGNAL( changed( const QColor & ) ) - , this, SIGNAL( shadowColorChanged( const QColor & ) ) ); +GeneralWidget::GeneralWidget(QWidget *parent) + : QWidget(parent) +{ + m_ui.setupUi(this); + connect(m_ui.kcfg_ShadowColor, SIGNAL(changed(const QColor &)) + , this, SIGNAL(shadowColorChanged(const QColor &))); } GeneralWidget::~GeneralWidget() { } diff --git a/engine/generalwidget.h b/engine/generalwidget.h index 1bbacf0..6bfd37a 100644 --- a/engine/generalwidget.h +++ b/engine/generalwidget.h @@ -28,60 +28,60 @@ #include "ui_generalconfig.h" class GeneralWidget : public QWidget { - Q_OBJECT - public: - GeneralWidget ( QWidget *parent ); - virtual ~GeneralWidget(); - - public: - inline int compactStyle() const { - Q_ASSERT ( m_ui.kcfg_CompactStyle->currentIndex() >= 0 - && m_ui.kcfg_CompactStyle->currentIndex() <= 2 ); - return m_ui.kcfg_CompactStyle->currentIndex(); - } - - inline bool showStop() const { - return m_ui.kcfg_ShowStop->isChecked(); - } - - inline bool showSeekSlider() const { - return m_ui.kcfg_ShowSeekSlider->isChecked(); - } - - inline bool showVolumeSlider() const { - return m_ui.kcfg_ShowVolumeSlider->isChecked(); - } - - inline int backgroundHint() const { - if ( m_ui.kcfg_NoBackground->isChecked() ) - return 0; - else if ( m_ui.kcfg_Normal->isChecked() ) - return 1; - - return 2; - } - - inline QColor shadowColor() const { - return m_ui.kcfg_ShadowColor->color(); - } - - inline bool noBackground() const { - return m_ui.kcfg_NoBackground->isChecked(); - } - - inline bool normal() const { - return m_ui.kcfg_Normal->isChecked(); - } - - inline bool translucent() const { - return m_ui.kcfg_Translucent->isChecked(); - } - - Q_SIGNALS: - void shadowColorChanged ( const QColor &color ); - - private: - mutable Ui::GeneralWidget m_ui; + Q_OBJECT +public: + GeneralWidget(QWidget *parent); + virtual ~GeneralWidget(); + +public: + inline int compactStyle() const { + Q_ASSERT(m_ui.kcfg_CompactStyle->currentIndex() >= 0 + && m_ui.kcfg_CompactStyle->currentIndex() <= 2); + return m_ui.kcfg_CompactStyle->currentIndex(); + } + + inline bool showStop() const { + return m_ui.kcfg_ShowStop->isChecked(); + } + + inline bool showSeekSlider() const { + return m_ui.kcfg_ShowSeekSlider->isChecked(); + } + + inline bool showVolumeSlider() const { + return m_ui.kcfg_ShowVolumeSlider->isChecked(); + } + + inline int backgroundHint() const { + if (m_ui.kcfg_NoBackground->isChecked()) + return 0; + else if (m_ui.kcfg_Normal->isChecked()) + return 1; + + return 2; + } + + inline QColor shadowColor() const { + return m_ui.kcfg_ShadowColor->color(); + } + + inline bool noBackground() const { + return m_ui.kcfg_NoBackground->isChecked(); + } + + inline bool normal() const { + return m_ui.kcfg_Normal->isChecked(); + } + + inline bool translucent() const { + return m_ui.kcfg_Translucent->isChecked(); + } + +Q_SIGNALS: + void shadowColorChanged(const QColor &color); + +private: + mutable Ui::GeneralWidget m_ui; }; #endif // GENERALWIDGET_H diff --git a/engine/playbar.cpp b/engine/playbar.cpp index 7e7ddc3..cfc323d 100644 --- a/engine/playbar.cpp +++ b/engine/playbar.cpp @@ -35,99 +35,109 @@ using namespace Plasma; -PlayBar::PlayBar( KSharedConfigPtr &config , QObject *parent ) - : QObject( parent ), - m_configDialog( nullptr ), - m_config( config ), - m_data( new Plasma::DataEngine::Data() ) { - m_dc = new DataEngineConsumer(); - m_collection = new KActionCollection( this, QLatin1String( "PlayBar" ) ); - m_collection->setComponentDisplayName( QLatin1String( "PlayBar" ) ); - - m_playpause = m_collection->addAction( QLatin1String( "play-pause" ), this, SLOT( slotPlayPause() ) ); - m_playpause->setIcon( QIcon::fromTheme( QLatin1String( "media-playback-start" ) ) ); - m_playpause->setText( i18n( "Play/Pause" ) ); - KGlobalAccel::setGlobalShortcut( m_playpause, Qt::Key_MediaPlay ); - - m_stop = m_collection->addAction( QLatin1String( "stop" ), this, SLOT( slotStop() ) ); - m_stop->setIcon( QIcon::fromTheme( QLatin1String( "media-playback-stop" ) ) ); - m_stop->setText( i18n( "Stop" ) ); - KGlobalAccel::setGlobalShortcut( m_stop, Qt::Key_MediaStop ); - - m_next = m_collection->addAction( QLatin1String( "next" ), this, SLOT( slotNext() ) ); - m_next->setIcon( QIcon::fromTheme( QLatin1String( "media-skip-forward" ) ) ); - m_next->setText( i18n( "Next track" ) ); - KGlobalAccel::setGlobalShortcut( m_next, Qt::Key_MediaNext ); - - m_previous = m_collection->addAction( QLatin1String( "previous" ), this, SLOT( slotPrevious() ) ); - m_previous->setIcon( QIcon::fromTheme( QLatin1String( "media-skip-backward" ) ) ); - m_previous->setText( i18n( "Previous track" ) ); - KGlobalAccel::setGlobalShortcut( m_previous, Qt::Key_MediaPrevious ); - - m_openMediaPlayer = m_collection->addAction( QLatin1String( "toggle-mediaplayer" ), this, - SLOT( slotToggleWinMediaPlayer() ) ); - m_openMediaPlayer->setText( i18n( "Toggle window media player" ) ); - KGlobalAccel::setGlobalShortcut( m_openMediaPlayer, QKeySequence() ); - - connect( m_configDialog, SIGNAL( settingsChanged( QString ) ), this, SLOT( loadSettings() ) ); +PlayBar::PlayBar(KSharedConfigPtr &config , QObject *parent) + : QObject(parent), + m_configDialog(nullptr), + m_config(config), + m_data(new Plasma::DataEngine::Data()) +{ + m_dc = new DataEngineConsumer(); + m_collection = new KActionCollection(this, QLatin1String("PlayBar")); + m_collection->setComponentDisplayName(QLatin1String("PlayBar")); + + m_playpause = m_collection->addAction(QLatin1String("play-pause"), this, SLOT(slotPlayPause())); + m_playpause->setIcon(QIcon::fromTheme(QLatin1String("media-playback-start"))); + m_playpause->setText(i18n("Play/Pause")); + KGlobalAccel::setGlobalShortcut(m_playpause, Qt::Key_MediaPlay); + + m_stop = m_collection->addAction(QLatin1String("stop"), this, SLOT(slotStop())); + m_stop->setIcon(QIcon::fromTheme(QLatin1String("media-playback-stop"))); + m_stop->setText(i18n("Stop")); + KGlobalAccel::setGlobalShortcut(m_stop, Qt::Key_MediaStop); + + m_next = m_collection->addAction(QLatin1String("next"), this, SLOT(slotNext())); + m_next->setIcon(QIcon::fromTheme(QLatin1String("media-skip-forward"))); + m_next->setText(i18n("Next track")); + KGlobalAccel::setGlobalShortcut(m_next, Qt::Key_MediaNext); + + m_previous = m_collection->addAction(QLatin1String("previous"), this, SLOT(slotPrevious())); + m_previous->setIcon(QIcon::fromTheme(QLatin1String("media-skip-backward"))); + m_previous->setText(i18n("Previous track")); + KGlobalAccel::setGlobalShortcut(m_previous, Qt::Key_MediaPrevious); + + m_openMediaPlayer = m_collection->addAction(QLatin1String("toggle-mediaplayer"), this, + SLOT(slotToggleWinMediaPlayer())); + m_openMediaPlayer->setText(i18n("Toggle window media player")); + KGlobalAccel::setGlobalShortcut(m_openMediaPlayer, QKeySequence()); + + connect(m_configDialog, SIGNAL(settingsChanged(QString)), this, SLOT(loadSettings())); } -PlayBar::~PlayBar() { +PlayBar::~PlayBar() +{ } -void PlayBar::slotPlayPause() { - startOperationOverMpris2( "PlayPause" ); +void PlayBar::slotPlayPause() +{ + startOperationOverMpris2("PlayPause"); } -void PlayBar::slotStop() { - startOperationOverMpris2( "Stop" ); +void PlayBar::slotStop() +{ + startOperationOverMpris2("Stop"); } -void PlayBar::slotNext() { - startOperationOverMpris2( "Next" ); +void PlayBar::slotNext() +{ + startOperationOverMpris2("Next"); } -void PlayBar::slotPrevious() { - startOperationOverMpris2( "Previous" ); +void PlayBar::slotPrevious() +{ + startOperationOverMpris2("Previous"); } -void PlayBar::slotToggleWinMediaPlayer() { - startOperationOverMpris2( "Raise" ); +void PlayBar::slotToggleWinMediaPlayer() +{ + startOperationOverMpris2("Raise"); } -void PlayBar::showSettings() { - if ( KConfigDialog::showDialog( ConfigDialog::CONFIG_NAME ) ) - return; - - //Read preferences from config file. - PlayBarSettings::self()->load(); - Q_ASSERT( m_collection ); - m_configDialog = new ConfigDialog( m_collection ); - - connect( this, SIGNAL( destroyed( QObject * ) ), m_configDialog, SLOT( deleteLater() ) ); - m_configDialog->show(); +void PlayBar::showSettings() +{ + if (KConfigDialog::showDialog(ConfigDialog::CONFIG_NAME)) + return; + + //Read preferences from config file. + PlayBarSettings::self()->load(); + Q_ASSERT(m_collection); + m_configDialog = new ConfigDialog(m_collection); + + connect(this, SIGNAL(destroyed(QObject *)), m_configDialog, SLOT(deleteLater())); + m_configDialog->show(); } -const DataEngine::Data &PlayBar::data() { - auto config = PlayBarSettings::self(); - // Read preferences from the KConfig object. - config->read(); - - m_data->insert( "CompactStyle", config->compactStyle() ); - m_data->insert( "ShowStop", config->showStop() ); - m_data->insert( "ShowVolumeSlider", config->showVolumeSlider() ); - m_data->insert( "ShowSeekSlider", config->showSeekSlider() ); - m_data->insert( "BackgroundHint", config->backgroundHint() ); - m_data->insert( "ShadowColor", config->shadowColor() ); - - return *m_data; +const DataEngine::Data &PlayBar::data() +{ + auto config = PlayBarSettings::self(); + // Read preferences from the KConfig object. + config->read(); + + m_data->insert("CompactStyle", config->compactStyle()); + m_data->insert("ShowStop", config->showStop()); + m_data->insert("ShowVolumeSlider", config->showVolumeSlider()); + m_data->insert("ShowSeekSlider", config->showSeekSlider()); + m_data->insert("BackgroundHint", config->backgroundHint()); + m_data->insert("ShadowColor", config->shadowColor()); + + return *m_data; } -inline void PlayBar::startOperationOverMpris2( const QString &name ) const { - DataEngine *mpris2 = m_dc->dataEngine( MPRIS2 ); - Service *serv = mpris2->serviceForSource( mpris2_source ); - const QVariantMap &op = serv->operationDescription( name ); - ServiceJob *job = serv->startOperationCall( op ); - connect( job, SIGNAL( finished( KJob * ) ), serv, SLOT( deleteLater() ) ); +inline void PlayBar::startOperationOverMpris2(const QString &name) const +{ + DataEngine *mpris2 = m_dc->dataEngine(MPRIS2); + Service *serv = mpris2->serviceForSource(mpris2_source); + const QVariantMap &op = serv->operationDescription(name); + ServiceJob *job = serv->startOperationCall(op); + connect(job, SIGNAL(finished(KJob *)), serv, SLOT(deleteLater())); } // kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/engine/playbar.h b/engine/playbar.h index f1b626a..debbf0b 100644 --- a/engine/playbar.h +++ b/engine/playbar.h @@ -31,51 +31,51 @@ using namespace Plasma; class PlayBar : public QObject { - Q_OBJECT - public: - - PlayBar ( KSharedConfigPtr &config, QObject *parent = 0 ); - - virtual ~PlayBar(); - - inline const QString &source() const { - return mpris2_source; - } - - inline void setSource ( const QString &source ) { - mpris2_source = source; - } - - const DataEngine::Data &data(); - - void startOperationOverMpris2 ( const QString &name ) const; - - public Q_SLOTS: - - void slotPlayPause(); - void slotStop(); - void slotNext(); - void slotPrevious(); - void slotToggleWinMediaPlayer(); - void showSettings(); - - private: - - ConfigDialog *m_configDialog = nullptr; - KActionCollection *m_collection = nullptr; - KSharedConfigPtr m_config; - DataEngine::Data *m_data = nullptr; - DataEngineConsumer *m_dc = nullptr; - static constexpr const char *MPRIS2 { "mpris2" }; - - QAction *m_playpause; - QAction *m_stop; - QAction *m_next; - QAction *m_previous; - QAction *m_openMediaPlayer; - - public: - QString mpris2_source = "@multiplex"; + Q_OBJECT +public: + + PlayBar(KSharedConfigPtr &config, QObject *parent = 0); + + virtual ~PlayBar(); + + inline const QString &source() const { + return mpris2_source; + } + + inline void setSource(const QString &source) { + mpris2_source = source; + } + + const DataEngine::Data &data(); + + void startOperationOverMpris2(const QString &name) const; + +public Q_SLOTS: + + void slotPlayPause(); + void slotStop(); + void slotNext(); + void slotPrevious(); + void slotToggleWinMediaPlayer(); + void showSettings(); + +private: + + ConfigDialog *m_configDialog = nullptr; + KActionCollection *m_collection = nullptr; + KSharedConfigPtr m_config; + DataEngine::Data *m_data = nullptr; + DataEngineConsumer *m_dc = nullptr; + static constexpr const char *MPRIS2 { "mpris2" }; + + QAction *m_playpause; + QAction *m_stop; + QAction *m_next; + QAction *m_previous; + QAction *m_openMediaPlayer; + +public: + QString mpris2_source = "@multiplex"; }; #endif // PLAYBAR_H diff --git a/engine/playbarengine.cpp b/engine/playbarengine.cpp index 9182dd6..ed434fa 100644 --- a/engine/playbarengine.cpp +++ b/engine/playbarengine.cpp @@ -26,47 +26,53 @@ #include "playbarservice.h" #include "playbarsettings.h" -PlayBarEngine::PlayBarEngine( QObject *parent, const QVariantList &args ) - : DataEngine( parent, args ) { - KSharedConfigPtr config = PlayBarSettings::self()->sharedConfig(); - m_playbar = new PlayBar( config, this ); - - setMinimumPollingInterval( 1000 ); - setPollingInterval( 0 ); - - connect( PlayBarSettings::self(), SIGNAL( configChanged() ), this, SLOT( updateData() ) ); +PlayBarEngine::PlayBarEngine(QObject *parent, const QVariantList &args) + : DataEngine(parent, args) +{ + KSharedConfigPtr config = PlayBarSettings::self()->sharedConfig(); + m_playbar = new PlayBar(config, this); + + setMinimumPollingInterval(1000); + setPollingInterval(0); + + connect(PlayBarSettings::self(), SIGNAL(configChanged()), this, SLOT(updateData())); } -PlayBarEngine::~PlayBarEngine() { - delete m_playbar; +PlayBarEngine::~PlayBarEngine() +{ + delete m_playbar; } -Service *PlayBarEngine::serviceForSource( const QString &source ) { - if ( source != PROVIDER ) - return nullptr; - - sourceRequestEvent( PROVIDER ); - Service *service = new PlayBarService( m_playbar, this ); - return service; +Service *PlayBarEngine::serviceForSource(const QString &source) +{ + if (source != PROVIDER) + return nullptr; + + sourceRequestEvent(PROVIDER); + Service *service = new PlayBarService(m_playbar, this); + return service; } -void PlayBarEngine::updateData() { - updateSourceEvent( PROVIDER ); +void PlayBarEngine::updateData() +{ + updateSourceEvent(PROVIDER); } -bool PlayBarEngine::sourceRequestEvent( const QString &source ) { - if ( source != PROVIDER ) - return false; - - updateSourceEvent( PROVIDER ); - return true; +bool PlayBarEngine::sourceRequestEvent(const QString &source) +{ + if (source != PROVIDER) + return false; + + updateSourceEvent(PROVIDER); + return true; } -bool PlayBarEngine::updateSourceEvent( const QString &source ) { - setData( source, m_playbar->data() ); - return true; +bool PlayBarEngine::updateSourceEvent(const QString &source) +{ + setData(source, m_playbar->data()); + return true; } -K_EXPORT_PLASMA_DATAENGINE_WITH_JSON( playbar, PlayBarEngine, "plasma-dataengine-playbar.json" ) +K_EXPORT_PLASMA_DATAENGINE_WITH_JSON(playbar, PlayBarEngine, "plasma-dataengine-playbar.json") #include "playbarengine.moc" // kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/engine/playbarengine.h b/engine/playbarengine.h index 61cb36b..93a6a06 100644 --- a/engine/playbarengine.h +++ b/engine/playbarengine.h @@ -28,28 +28,28 @@ using namespace Plasma; class PlayBarEngine : public DataEngine { - Q_OBJECT - public: - - PlayBarEngine ( QObject *parent, const QVariantList &args ); - - virtual ~PlayBarEngine(); - - public: - Service *serviceForSource ( const QString &source ) override; - - private Q_SLOTS: - void updateData(); - - protected: - bool sourceRequestEvent ( const QString &source ) override; - bool updateSourceEvent ( const QString &source ) override; - - private: - static constexpr const char *PROVIDER { - "Provider" - }; - PlayBar *m_playbar; + Q_OBJECT +public: + + PlayBarEngine(QObject *parent, const QVariantList &args); + + virtual ~PlayBarEngine(); + +public: + Service *serviceForSource(const QString &source) override; + +private Q_SLOTS: + void updateData(); + +protected: + bool sourceRequestEvent(const QString &source) override; + bool updateSourceEvent(const QString &source) override; + +private: + static constexpr const char *PROVIDER { + "Provider" + }; + PlayBar *m_playbar; }; #endif // PLAYBARENGINE_H diff --git a/engine/playbarjob.cpp b/engine/playbarjob.cpp index 05082ad..30140f9 100644 --- a/engine/playbarjob.cpp +++ b/engine/playbarjob.cpp @@ -23,27 +23,30 @@ #include "playbar.h" -PlayBarJob::PlayBarJob( const QString &destination, - const QString &operation, - const QVariantMap ¶meters, - PlayBar *playbar, - QObject *parent ) : - ServiceJob( destination, operation, parameters, parent ), - m_playbar( playbar ) { - +PlayBarJob::PlayBarJob(const QString &destination, + const QString &operation, + const QVariantMap ¶meters, + PlayBar *playbar, + QObject *parent) : + ServiceJob(destination, operation, parameters, parent), + m_playbar(playbar) +{ + } -PlayBarJob::~PlayBarJob() { - // qDebug() << this << "deleted"; +PlayBarJob::~PlayBarJob() +{ + // qDebug() << this << "deleted"; } -void PlayBarJob::start() { - if ( operationName() == QLatin1String( "ShowSettings" ) ) - m_playbar->showSettings(); - - if ( operationName() == QLatin1String( "SetSourceMpris2" ) ) - m_playbar->mpris2_source = parameters()["source"].toString(); - - emitResult(); +void PlayBarJob::start() +{ + if (operationName() == QLatin1String("ShowSettings")) + m_playbar->showSettings(); + + if (operationName() == QLatin1String("SetSourceMpris2")) + m_playbar->mpris2_source = parameters()["source"].toString(); + + emitResult(); } // kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/engine/playbarjob.h b/engine/playbarjob.h index 7613fc3..b0dd7de 100644 --- a/engine/playbarjob.h +++ b/engine/playbarjob.h @@ -27,21 +27,21 @@ using namespace Plasma; class PlayBarJob : public ServiceJob { - public: - - PlayBarJob ( const QString &destination, - const QString &operation, - const QVariantMap ¶meters, - PlayBar *playbar, - QObject *parent = nullptr ); - - virtual ~PlayBarJob(); - - void start() override; - - private: - - PlayBar *m_playbar; +public: + + PlayBarJob(const QString &destination, + const QString &operation, + const QVariantMap ¶meters, + PlayBar *playbar, + QObject *parent = nullptr); + + virtual ~PlayBarJob(); + + void start() override; + +private: + + PlayBar *m_playbar; }; #endif // PLAYBARJOB_H diff --git a/engine/playbarservice.cpp b/engine/playbarservice.cpp index 12150d2..c10cdeb 100644 --- a/engine/playbarservice.cpp +++ b/engine/playbarservice.cpp @@ -27,17 +27,20 @@ #include "Plasma/ServiceJob" -PlayBarService::PlayBarService( PlayBar *playbar, QObject *parent ) - : Service( parent ), - m_playbar( playbar ) { - setName( QLatin1Literal( "audoban.engine.playbar" ) ); +PlayBarService::PlayBarService(PlayBar *playbar, QObject *parent) + : Service(parent), + m_playbar(playbar) +{ + setName(QLatin1Literal("audoban.engine.playbar")); } -PlayBarService::~PlayBarService() { - // qDebug() << this << "deleted"; +PlayBarService::~PlayBarService() +{ + // qDebug() << this << "deleted"; } -ServiceJob *PlayBarService::createJob( const QString &operation, QVariantMap ¶meters ) { - return new PlayBarJob( destination(), operation, parameters, m_playbar, this ); +ServiceJob *PlayBarService::createJob(const QString &operation, QVariantMap ¶meters) +{ + return new PlayBarJob(destination(), operation, parameters, m_playbar, this); } // kate: indent-mode cstyle; indent-width 4; replace-tabs on; diff --git a/engine/playbarservice.h b/engine/playbarservice.h index 2ccf380..a345412 100644 --- a/engine/playbarservice.h +++ b/engine/playbarservice.h @@ -28,18 +28,18 @@ using namespace Plasma; class PlayBarService : public Service { - Q_OBJECT - public: - - PlayBarService ( PlayBar *playbar, QObject *parent = 0 ); - - virtual ~PlayBarService(); - - protected: - ServiceJob *createJob ( const QString &operation, QVariantMap ¶meters ) override; - - private: - PlayBar *m_playbar; + Q_OBJECT +public: + + PlayBarService(PlayBar *playbar, QObject *parent = 0); + + virtual ~PlayBarService(); + +protected: + ServiceJob *createJob(const QString &operation, QVariantMap ¶meters) override; + +private: + PlayBar *m_playbar; }; #endif // PLAYBARSERVICE_H diff --git a/engine/playbarsettings.h b/engine/playbarsettings.h new file mode 100644 index 0000000..102d988 --- /dev/null +++ b/engine/playbarsettings.h @@ -0,0 +1,197 @@ +// This file is generated by kconfig_compiler_kf5 from playbar.kcfg. +// All changes you do to this file will be lost. +#ifndef PLAYBARSETTINGS_H +#define PLAYBARSETTINGS_H + +#include +#include +#include + +class PlayBarSettings : public KConfigSkeleton { +public: + class EnumCompactStyle { + public: + enum type { Icon, PlaybackButtons, PlayPauseAndSeek, PlayPauseAndInfo, COUNT }; + }; + class EnumBackgroundHint { + public: + enum type { None, Normal, Translucent, COUNT }; + }; + + static PlayBarSettings *self(); + ~PlayBarSettings(); + + /** + Set CompactStyle + */ + static + void setCompactStyle(int v) { + if (!self()->isImmutable(QStringLiteral("CompactStyle"))) + self()->mCompactStyle = v; + } + + /** + Get CompactStyle + */ + static + int compactStyle() { + return self()->mCompactStyle; + } + + /** + Set ShowStop + */ + static + void setShowStop(bool v) { + if (!self()->isImmutable(QStringLiteral("ShowStop"))) + self()->mShowStop = v; + } + + /** + Get ShowStop + */ + static + bool showStop() { + return self()->mShowStop; + } + + /** + Set ShowSeekSlider + */ + static + void setShowSeekSlider(bool v) { + if (!self()->isImmutable(QStringLiteral("ShowSeekSlider"))) + self()->mShowSeekSlider = v; + } + + /** + Get ShowSeekSlider + */ + static + bool showSeekSlider() { + return self()->mShowSeekSlider; + } + + /** + Set ShowVolumeSlider + */ + static + void setShowVolumeSlider(bool v) { + if (!self()->isImmutable(QStringLiteral("ShowVolumeSlider"))) + self()->mShowVolumeSlider = v; + } + + /** + Get ShowVolumeSlider + */ + static + bool showVolumeSlider() { + return self()->mShowVolumeSlider; + } + + /** + Set BackgroundHint + */ + static + void setBackgroundHint(int v) { + if (!self()->isImmutable(QStringLiteral("BackgroundHint"))) + self()->mBackgroundHint = v; + } + + /** + Get BackgroundHint + */ + static + int backgroundHint() { + return self()->mBackgroundHint; + } + + /** + Set ShadowColor + */ + static + void setShadowColor(const QColor &v) { + if (!self()->isImmutable(QStringLiteral("ShadowColor"))) + self()->mShadowColor = v; + } + + /** + Get ShadowColor + */ + static + QColor shadowColor() { + return self()->mShadowColor; + } + + /** + Set Normal + */ + static + void setNormal(bool v) { + if (!self()->isImmutable(QStringLiteral("Normal"))) + self()->mNormal = v; + } + + /** + Get Normal + */ + static + bool normal() { + return self()->mNormal; + } + + /** + Set Translucent + */ + static + void setTranslucent(bool v) { + if (!self()->isImmutable(QStringLiteral("Translucent"))) + self()->mTranslucent = v; + } + + /** + Get Translucent + */ + static + bool translucent() { + return self()->mTranslucent; + } + + /** + Set NoBackground + */ + static + void setNoBackground(bool v) { + if (!self()->isImmutable(QStringLiteral("NoBackground"))) + self()->mNoBackground = v; + } + + /** + Get NoBackground + */ + static + bool noBackground() { + return self()->mNoBackground; + } + +protected: + PlayBarSettings(); + friend class PlayBarSettingsHelper; + + + // General + int mCompactStyle; + bool mShowStop; + bool mShowSeekSlider; + bool mShowVolumeSlider; + int mBackgroundHint; + QColor mShadowColor; + bool mNormal; + bool mTranslucent; + bool mNoBackground; + +private: +}; + +#endif +