Skip to content

Commit

Permalink
C++ code formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmitar committed Jun 2, 2017
1 parent ff548de commit c3dede7
Show file tree
Hide file tree
Showing 14 changed files with 611 additions and 379 deletions.
54 changes: 31 additions & 23 deletions .astylerc
Original file line number Diff line number Diff line change
@@ -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
106 changes: 55 additions & 51 deletions engine/configdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
40 changes: 20 additions & 20 deletions engine/configdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions engine/generalwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() { }
Expand Down
108 changes: 54 additions & 54 deletions engine/generalwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit c3dede7

Please sign in to comment.