From e6bc55389083aaa81bf912d979ef11f30b3631a9 Mon Sep 17 00:00:00 2001 From: zJes Date: Tue, 13 Oct 2020 18:46:23 +0200 Subject: [PATCH] Fixed obsolete methods, clang format, added kvantum theme --- .clang-format | 91 +++++++++++++++++++ CMakeLists.txt | 3 - config/config.cpp | 30 +++--- config/config.h | 14 +-- config/main.cpp | 6 +- .../themes/kvantum/lxqt-app-switcher.qss | 20 ++++ src/app-itemdelegate.cpp | 43 ++++----- src/app-itemdelegate.h | 10 +- src/app-model.cpp | 50 +++++----- src/app-model.h | 18 ++-- src/app-switcher.cpp | 79 +++++++++------- src/app-switcher.h | 24 +++-- src/main.cpp | 35 ++++--- src/settings.h | 77 ++++++++++++---- 14 files changed, 341 insertions(+), 159 deletions(-) create mode 100644 .clang-format create mode 100644 resources/themes/kvantum/lxqt-app-switcher.qss diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..09858e6 --- /dev/null +++ b/.clang-format @@ -0,0 +1,91 @@ +IncludeCategories: + - Regex: '^<' + Priority: 10 + - Regex: '^"' + Priority: 1 + +AlignAfterOpenBracket: DontAlign +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: true +AlignEscapedNewlinesLeft: false +AlignOperands: true +AlignTrailingComments: true +AlignConsecutiveMacros: true +AllowAllParametersOfDeclarationOnNextLine: false +AccessModifierOffset: -4 +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AllowAllConstructorInitializersOnNextLine: true + +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +#AlwaysBreakAfterReturnType: All + +BinPackArguments: true +BinPackParameters: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeTernaryOperators: true +ColumnLimit: 120 +BreakConstructorInitializers: BeforeComma +ConstructorInitializerAllOnOneLineOrOnePerLine: false +CommentPragmas: '^ IWYU pragma:' +BreakBeforeBraces: Custom +BraceWrapping: + AfterEnum: true + AfterStruct: true + AfterClass: true + AfterControlStatement: false + AfterFunction: true + AfterNamespace: false + BeforeElse: false + + +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true + +DerivePointerAlignment: false +ExperimentalAutoDetectBinPacking: false +IndentCaseLabels: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +IncludeBlocks: Merge +KeepEmptyLinesAtTheStartOfBlocks: true + +Language: Cpp + +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: Inner +CompactNamespaces: true + +PenaltyBreakBeforeFirstCallParameter: 9999999 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 9999999 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 9999999 + +PointerAlignment: Left + +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +SpaceBeforeCtorInitializerColon: false + +Standard: Cpp11 +TabWidth: 4 +UseTab: Never +IndentCaseLabels: true + +AllowShortLambdasOnASingleLine: None diff --git a/CMakeLists.txt b/CMakeLists.txt index c0a21c2..d4b1832 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,9 +16,6 @@ set(CMAKE_AUTOMOC ON) option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts files" OFF) -add_definitions("-g -fPIC -Wall -Wextra -pedantic -Wformat=2 -Wnon-virtual-dtor -std=c++11 -Wl,--as-needed -z relro -z defs") - - set(files src/app-switcher.cpp src/app-switcher.h diff --git a/config/config.cpp b/config/config.cpp index d976f8f..226e463 100644 --- a/config/config.cpp +++ b/config/config.cpp @@ -25,16 +25,16 @@ * END_COMMON_COPYRIGHT_HEADER */ #include "config.h" -#include "ui_config.h" #include "../src/settings.h" +#include "ui_config.h" -Config::Config(QWidget *parent) : - QDialog(parent), - m_ui(new Ui::Config) +Config::Config(QWidget* parent) + : QDialog(parent) + , m_ui(new Ui::Config) { m_ui->setupUi(this); - Settings & set = Settings::instance(); + Settings& set = Settings::instance(); m_ui->iconSizeEdt->setValue(set.iconSize()); m_ui->maxItemsEdt->setValue(set.maxDisplayApps()); m_ui->maxLengthEdt->setValue(set.maxTextWidth()); @@ -45,14 +45,22 @@ Config::Config(QWidget *parent) : m_ui->fontSize->setValue(set.customFontSize() ? set.customFontSize() : qApp->font().pointSize()); m_ui->fontSize->setEnabled(set.customFontSizeEnabled()); - connect(m_ui->iconSizeEdt, static_cast(&QSpinBox::valueChanged), [this](int){ save(); }); - connect(m_ui->maxItemsEdt, static_cast(&QSpinBox::valueChanged), [this](int){ save(); }); - connect(m_ui->maxLengthEdt, static_cast(&QSpinBox::valueChanged), [this](int){ save(); }); - connect(m_ui->fontSize, static_cast(&QSpinBox::valueChanged), [this](int){ save(); }); + connect(m_ui->iconSizeEdt, static_cast(&QSpinBox::valueChanged), [this](int) { + save(); + }); + connect(m_ui->maxItemsEdt, static_cast(&QSpinBox::valueChanged), [this](int) { + save(); + }); + connect(m_ui->maxLengthEdt, static_cast(&QSpinBox::valueChanged), [this](int) { + save(); + }); + connect(m_ui->fontSize, static_cast(&QSpinBox::valueChanged), [this](int) { + save(); + }); connect(m_ui->filterDskChk, &QCheckBox::stateChanged, this, &Config::save); connect(m_ui->filterScrChk, &QCheckBox::stateChanged, this, &Config::save); - connect(m_ui->fontSizeEnabled, &QCheckBox::stateChanged, [this](int state){ + connect(m_ui->fontSizeEnabled, &QCheckBox::stateChanged, [this](int state) { m_ui->fontSize->setEnabled(state); save(); }); @@ -65,7 +73,7 @@ Config::~Config() void Config::save() { - Settings & set = Settings::instance(); + Settings& set = Settings::instance(); set.setIconSize(m_ui->iconSizeEdt->value()); set.setDisplayApps(m_ui->maxItemsEdt->value()); diff --git a/config/config.h b/config/config.h index d45efcd..cac3eaf 100644 --- a/config/config.h +++ b/config/config.h @@ -28,18 +28,20 @@ #include -namespace Ui -{ class Config; } +namespace Ui { +class Config; +} class Config : public QDialog { Q_OBJECT public: - explicit Config(QWidget *parent = 0); + explicit Config(QWidget* parent = 0); virtual ~Config(); + private: void save(); -private: - Ui::Config *m_ui; -}; +private: + Ui::Config* m_ui; +}; diff --git a/config/main.cpp b/config/main.cpp index 3a36838..4c3fd09 100644 --- a/config/main.cpp +++ b/config/main.cpp @@ -24,13 +24,13 @@ * * END_COMMON_COPYRIGHT_HEADER */ -#include #include "config.h" +#include -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { LXQt::Application app(argc, argv); - Config conf; + Config conf; conf.show(); return app.exec(); } diff --git a/resources/themes/kvantum/lxqt-app-switcher.qss b/resources/themes/kvantum/lxqt-app-switcher.qss new file mode 100644 index 0000000..a9574d2 --- /dev/null +++ b/resources/themes/kvantum/lxqt-app-switcher.qss @@ -0,0 +1,20 @@ +AppSwitcher { + /*border-width: 1px; + border-color: #dedede; + border-style: outset;*/ + + color: #FFFFFF; + padding: 5px; + margin: 0px; + + background:qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 rgba(100, 100, 100, 80%), stop:0.11 rgba(80, 80, 80, 80%), stop:0.12 rgba(80, 80, 80, 80%), stop:1 rgba(0, 0, 0, 72%)); + border-radius: 5px; +} + +AppSwitcher::item:selected { + border-width: 1px; + border-color: #5e5e5e; + border-style: solid; + border-radius: 5px; + background-color:qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #3a5f84, stop:0.31 #345372, stop:0.32 #2e4964, stop:1 #4584be); +} diff --git a/src/app-itemdelegate.cpp b/src/app-itemdelegate.cpp index 7568df8..6f23da0 100644 --- a/src/app-itemdelegate.cpp +++ b/src/app-itemdelegate.cpp @@ -24,56 +24,53 @@ * * END_COMMON_COPYRIGHT_HEADER */ +#include "app-itemdelegate.h" +#include "app-model.h" +#include "settings.h" +#include #include #include -#include -#include "app-model.h" -#include "app-itemdelegate.h" -#include "settings.h" -AppItemDelegate::AppItemDelegate(QObject *parent): - QStyledItemDelegate(parent) +AppItemDelegate::AppItemDelegate(QObject* parent) + : QStyledItemDelegate(parent) { } void AppItemDelegate::init() { - m_iconSize = Settings::instance().iconSize(); + m_iconSize = Settings::instance().iconSize(); m_maxTextWidth = Settings::instance().maxTextWidth(); } -void AppItemDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const +void AppItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { - QStyle *style = option.widget ? option.widget->style() : QApplication::style(); + QStyle* style = option.widget ? option.widget->style() : QApplication::style(); style->drawControl(QStyle::CE_ItemViewItem, &option, painter, option.widget); QPixmap img = index.model()->data(index, AppRole::Icon).value(); - painter->drawPixmap(option.rect.left()+2, option.rect.top()+2, m_iconSize, m_iconSize, img); + painter->drawPixmap(option.rect.left() + 2, option.rect.top() + 2, m_iconSize, m_iconSize, img); QString text = index.model()->data(index, AppRole::Display).toString(); - if (text.length() > m_maxTextWidth){ - text = text.left(m_maxTextWidth)+"..."; + if (text.length() > m_maxTextWidth) { + text = text.left(m_maxTextWidth) + "..."; } painter->setFont(option.font); - painter->drawText( - QRectF(option.rect.left()+m_iconSize+5, option.rect.top()+2, option.rect.width()-m_iconSize-5, m_iconSize), - Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, - text - ); + painter->drawText(QRectF(option.rect.left() + m_iconSize + 5, option.rect.top() + 2, + option.rect.width() - m_iconSize - 5, m_iconSize), + Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, text); } -QSize AppItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +QSize AppItemDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const { QFontMetrics m(option.font); - QString text = index.model()->data(index, AppRole::Display).toString(); + QString text = index.model()->data(index, AppRole::Display).toString(); - if (text.length() > m_maxTextWidth){ - text = text.left(m_maxTextWidth)+"..."; + if (text.length() > m_maxTextWidth) { + text = text.left(m_maxTextWidth) + "..."; } - return QSize(m_iconSize + 10 + m.width(text), m_iconSize+4); + return QSize(m_iconSize + 10 + m.horizontalAdvance(text), m_iconSize + 4); } - diff --git a/src/app-itemdelegate.h b/src/app-itemdelegate.h index 6a205ef..d347373 100644 --- a/src/app-itemdelegate.h +++ b/src/app-itemdelegate.h @@ -27,15 +27,17 @@ #pragma once #include -class AppItemDelegate: public QStyledItemDelegate +class AppItemDelegate : public QStyledItemDelegate { Q_OBJECT public: - AppItemDelegate(QObject *parent); + AppItemDelegate(QObject* parent); void init(); + protected: - virtual void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const; - virtual QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; + virtual void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const; + virtual QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const; + private: int m_iconSize; int m_maxTextWidth = 0; diff --git a/src/app-model.cpp b/src/app-model.cpp index 9e3f181..3faf1b5 100644 --- a/src/app-model.cpp +++ b/src/app-model.cpp @@ -24,51 +24,53 @@ * * END_COMMON_COPYRIGHT_HEADER */ -#include -#include -#include -#include #include "app-model.h" #include "settings.h" +#include +#include +#include +#include +#include -AppModel::AppModel(QObject *parent): - QAbstractListModel(parent) +AppModel::AppModel(QObject* parent) + : QAbstractListModel(parent) { create(); } void AppModel::create() { - int iconSize = Settings::instance().iconSize(); - bool byDesk = Settings::instance().filterCurrentDesktop(); + int iconSize = Settings::instance().iconSize(); + bool byDesk = Settings::instance().filterCurrentDesktop(); bool byScreen = Settings::instance().filterCurrentScreen(); - for(WId wid: KWindowSystem::stackingOrder()){ - KWindowInfo info(wid, NET::WMVisibleName | NET::WMState | NET::XAWMState | NET::WMWindowType); + for (WId wid : KWindowSystem::stackingOrder()) { + KWindowInfo info(wid, NET::WMVisibleName | NET::WMState | NET::XAWMState | NET::WMWindowType); NET::WindowType type = info.windowType(NET::AllTypesMask); - if(!info.hasState(NET::SkipTaskbar) && (type == NET::Normal || type == NET::Dialog || type == NET::Unknown) && filter(wid, byDesk, byScreen)){ + if (!info.hasState(NET::SkipTaskbar) && (type == NET::Normal || type == NET::Dialog || type == NET::Unknown) && + filter(wid, byDesk, byScreen)) { m_list.prepend({wid, info.visibleName(), KWindowSystem::icon(wid, iconSize, iconSize, true)}); } } } -int AppModel::rowCount(const QModelIndex &/*parent*/) const +int AppModel::rowCount(const QModelIndex& /*parent*/) const { return m_list.size(); } -QVariant AppModel::data(const QModelIndex &index, int role) const +QVariant AppModel::data(const QModelIndex& index, int role) const { if (!index.isValid() || index.row() >= m_list.size()) return QVariant(); - switch(role){ - case AppRole::Display: - return m_list[index.row()].name; - case AppRole::Icon: - return m_list[index.row()].pixmap; - case AppRole::Window: - return m_list[index.row()].windowId; + switch (role) { + case AppRole::Display: + return m_list[index.row()].name; + case AppRole::Icon: + return m_list[index.row()].pixmap; + case AppRole::Window: + return m_list[index.row()].windowId; } return QVariant(); } @@ -76,14 +78,16 @@ QVariant AppModel::data(const QModelIndex &index, int role) const bool AppModel::filter(WId window, bool byDesk, bool byScreen) const { KWindowInfo info(window, NET::WMDesktop | NET::WMFrameExtents); - if (byDesk){ - if (KWindowSystem::currentDesktop() != info.desktop() && info.desktop() != NET::OnAllDesktops) + if (byDesk) { + if (KWindowSystem::currentDesktop() != info.desktop() && info.desktop() != NET::OnAllDesktops) { return false; + } } if (byScreen) { - if (!QApplication::desktop()->screenGeometry(QCursor::pos()).intersects(info.frameGeometry())) + if (!QGuiApplication::screenAt(QCursor::pos())->geometry().intersects(info.frameGeometry())) { return false; + } } return true; } diff --git a/src/app-model.h b/src/app-model.h index e822423..2a3e6e7 100644 --- a/src/app-model.h +++ b/src/app-model.h @@ -26,8 +26,8 @@ #pragma once -#include #include +#include struct AppInfo { @@ -37,10 +37,11 @@ struct AppInfo }; namespace AppRole { -enum Role { +enum Role +{ Display = Qt::DisplayRole, - Icon = Qt::UserRole + 1, - Window = Qt::UserRole +2 + Icon = Qt::UserRole + 1, + Window = Qt::UserRole + 2 }; } @@ -48,13 +49,16 @@ class AppModel : public QAbstractListModel { Q_OBJECT public: - AppModel(QObject *parent); + AppModel(QObject* parent); + protected: - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; + virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; + private: void create(); bool filter(WId window, bool byDesk, bool byScreen) const; + private: QList m_list; }; diff --git a/src/app-switcher.cpp b/src/app-switcher.cpp index 76ead0f..977f0e4 100644 --- a/src/app-switcher.cpp +++ b/src/app-switcher.cpp @@ -24,41 +24,47 @@ * * END_COMMON_COPYRIGHT_HEADER */ -#include -#include -#include +#include "app-itemdelegate.h" +#include "app-model.h" +#include "settings.h" #include #include +#include +#include +#include #include +#include #include #include +// Should be after Qt headers #include "app-switcher.h" -#include "app-model.h" -#include "app-itemdelegate.h" -#include "settings.h" -AppSwitcher::AppSwitcher(QWidget *parent): - QListView(parent) +AppSwitcher::AppSwitcher(QWidget* parent) + : QListView(parent) { setWindowFlags(Qt::Dialog | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint); setObjectName("AppSwitcher"); - m_globalShortcut = GlobalKeyShortcut::Client::instance()->addAction("Alt+Tab", "/app_switcher/switch", tr("Switch applications"), this); - m_globalRShortcut = GlobalKeyShortcut::Client::instance()->addAction("Shift+Alt+Tab", "/app_switcher/rswitch", tr("Reverse switch applications"), this); + m_globalShortcut = GlobalKeyShortcut::Client::instance()->addAction( + "Alt+Tab", "/app_switcher/switch", tr("Switch applications"), this); + m_globalRShortcut = GlobalKeyShortcut::Client::instance()->addAction( + "Shift+Alt+Tab", "/app_switcher/rswitch", tr("Reverse switch applications"), this); - connect(m_globalShortcut, &GlobalKeyShortcut::Action::activated, [this]{ - if (isVisible()) + connect(m_globalShortcut, &GlobalKeyShortcut::Action::activated, [this] { + if (isVisible()) { selectItem(); - else + } else { showSwitcher(); + } }); - connect(m_globalRShortcut, &GlobalKeyShortcut::Action::activated, [this]{ - if (isVisible()) + connect(m_globalRShortcut, &GlobalKeyShortcut::Action::activated, [this] { + if (isVisible()) { selectItem(false); - else + } else { showSwitcher(false); + } }); setItemDelegate(new AppItemDelegate(this)); @@ -78,12 +84,13 @@ void AppSwitcher::showSwitcher(bool forward) m_current = 0; - if (!model()->rowCount()) + if (!model()->rowCount()) { return; + } QStyleOptionViewItem option; - QFont fnt = font(); - if (Settings::instance().customFontSizeEnabled()){ + QFont fnt = font(); + if (Settings::instance().customFontSizeEnabled()) { int fontSize = Settings::instance().customFontSize(); fnt.setPointSize(fontSize); option.font.setPointSize(fontSize); @@ -93,22 +100,23 @@ void AppSwitcher::showSwitcher(bool forward) } setFont(fnt); - int w = 0; - int h = 0; + int w = 0; + int h = 0; int maxApp = Settings::instance().maxDisplayApps(); - for(int i = 0; i < model()->rowCount(); ++i){ + for (int i = 0; i < model()->rowCount(); ++i) { QSize siz = itemDelegate()->sizeHint(option, model()->index(i, 0)); - w = qMax(w, siz.width()); + w = qMax(w, siz.width()); h += siz.height(); if (i > maxApp) break; } - resize(w+contentsMargins().left()+contentsMargins().right(), h+contentsMargins().top()+contentsMargins().bottom()); + resize(w + contentsMargins().left() + contentsMargins().right(), + h + contentsMargins().top() + contentsMargins().bottom()); - QRect active = QApplication::desktop()->screenGeometry(QCursor::pos()); - move(active.left()+active.width()/2 - width() / 2, active.top()+active.height()/2 - height() / 2); + QRect active = QGuiApplication::screenAt(QCursor::pos())->geometry(); + move(active.left() + active.width() / 2 - width() / 2, active.top() + active.height() / 2 - height() / 2); selectItem(forward); show(); m_timer->start(); @@ -118,10 +126,12 @@ void AppSwitcher::selectItem(bool forward) { m_timer->start(); m_current += forward ? 1 : -1; - if(m_current >= model()->rowCount()) + if (m_current >= model()->rowCount()) { m_current = 0; - if(m_current < 0) - m_current = model()->rowCount()-1; + } + if (m_current < 0) { + m_current = model()->rowCount() - 1; + } setCurrentIndex(model()->index(m_current, 0)); } @@ -130,15 +140,16 @@ void AppSwitcher::activateWindow(WId id) { KWindowInfo info(id, NET::WMDesktop); - if (KWindowSystem::currentDesktop() != info.desktop()) + if (KWindowSystem::currentDesktop() != info.desktop()) { KWindowSystem::setCurrentDesktop(info.desktop()); + } KWindowSystem::forceActiveWindow(id); } -void AppSwitcher::keyReleaseEvent(QKeyEvent *event) +void AppSwitcher::keyReleaseEvent(QKeyEvent* event) { - if (event->modifiers() == 0){ + if (event->modifiers() == 0) { close(); activateWindow(model()->data(model()->index(m_current, 0), AppRole::Window).value()); } @@ -147,7 +158,7 @@ void AppSwitcher::keyReleaseEvent(QKeyEvent *event) void AppSwitcher::timer() { - if (QApplication::queryKeyboardModifiers() == Qt::NoModifier){ + if (QApplication::queryKeyboardModifiers() == Qt::NoModifier) { close(); activateWindow(model()->data(model()->index(m_current, 0), AppRole::Window).value()); } else { @@ -155,7 +166,7 @@ void AppSwitcher::timer() } } -void AppSwitcher::closeEvent(QCloseEvent *) +void AppSwitcher::closeEvent(QCloseEvent*) { m_timer->stop(); } diff --git a/src/app-switcher.h b/src/app-switcher.h index bd0f626..0d62201 100644 --- a/src/app-switcher.h +++ b/src/app-switcher.h @@ -30,25 +30,29 @@ #include #include -namespace GlobalKeyShortcut -{ class Action; } +namespace GlobalKeyShortcut { +class Action; +} -class AppSwitcher: public QListView +class AppSwitcher : public QListView { Q_OBJECT public: - AppSwitcher(QWidget *parent); + AppSwitcher(QWidget* parent); + protected: - void keyReleaseEvent(QKeyEvent *event) override; - void closeEvent(QCloseEvent *) override; + void keyReleaseEvent(QKeyEvent* event) override; + void closeEvent(QCloseEvent*) override; + private: void showSwitcher(bool forward = true); void selectItem(bool forward = true); void timer(); void activateWindow(WId id); + private: - GlobalKeyShortcut::Action *m_globalShortcut; - GlobalKeyShortcut::Action *m_globalRShortcut; - QTimer *m_timer; - int m_current = 0; + GlobalKeyShortcut::Action* m_globalShortcut; + GlobalKeyShortcut::Action* m_globalRShortcut; + QTimer* m_timer; + int m_current = 0; }; diff --git a/src/main.cpp b/src/main.cpp index b1eb5db..27915b7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,38 +24,43 @@ * * END_COMMON_COPYRIGHT_HEADER */ -#include -#include -#include -#include -#include -#include "src/app-switcher.h" #include "src/settings.h" +#include +#include +#include +#include +#include + +// Should be after Qt headers +#include "src/app-switcher.h" LXQt::LXQtTheme currentTheme() { - QString themeName = Settings::instance().theme(); - for(const LXQt::LXQtTheme & theme: LXQt::LXQtTheme::allThemes()){ - if (theme.name() == themeName) + QString themeName = "kvantum";//Settings::instance().theme(); + qWarning() << "theme name" << themeName; + for (const LXQt::LXQtTheme& theme : LXQt::LXQtTheme::allThemes()) { + if (theme.name() == themeName) { + qWarning() << "a1"; return theme; + } } + qWarning() << "a2"; return LXQt::LXQtTheme::currentTheme(); } -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { LXQt::Application app(argc, argv); app.setQuitOnLastWindowClosed(false); LXQt::LXQtTheme theme = currentTheme(); - qDebug() << theme.name(); - if(QFile::exists(theme.path()+"/lxqt-app-switcher.qss")){ - app.setStyleSheet( "file:///" + theme.path()+"/lxqt-app-switcher.qss"); + if (QFile::exists(theme.path() + "/lxqt-app-switcher.qss")) { + qWarning() << "theme path" << theme.path(); + app.setStyleSheet("file:///" + theme.path() + "/lxqt-app-switcher.qss"); } - QWidget hiddenPreviewParent(0, Qt::Tool); + QWidget hiddenPreviewParent(0, Qt::Tool); AppSwitcher switcher(&hiddenPreviewParent); return app.exec(); } - diff --git a/src/settings.h b/src/settings.h index ee55460..8c03020 100644 --- a/src/settings.h +++ b/src/settings.h @@ -37,59 +37,96 @@ public: } QString theme() const - { return m_sets.value("appearance/lxqt-theme", "ambiance").toString(); } + { + return m_sets.value("appearance/lxqt-theme", "ambiance").toString(); + } void setTheme(const QString& theme) - { m_sets.setValue("appearance/lxqt-theme", theme); } + { + m_sets.setValue("appearance/lxqt-theme", theme); + } int iconSize() const - { return m_sets.value("appearance/icon-size", 38).toInt(); } + { + return m_sets.value("appearance/icon-size", 38).toInt(); + } void setIconSize(int size) - { m_sets.setValue("appearance/icon-size", size); } + { + m_sets.setValue("appearance/icon-size", size); + } int maxDisplayApps() const - { return m_sets.value("appearance/max-disp-apps", 15).toInt(); } + { + return m_sets.value("appearance/max-disp-apps", 15).toInt(); + } void setDisplayApps(int size) - { m_sets.setValue("appearance/max-disp-apps", size); } + { + m_sets.setValue("appearance/max-disp-apps", size); + } int maxTextWidth() const - { return m_sets.value("appearance/max-text-width", 50).toInt(); } + { + return m_sets.value("appearance/max-text-width", 50).toInt(); + } void setMaxTextWidth(int width) - { m_sets.setValue("appearance/max-text-width", width); } + { + m_sets.setValue("appearance/max-text-width", width); + } bool filterCurrentDesktop() const - { return m_sets.value("filter/current-desktop", true).toBool(); } + { + return m_sets.value("filter/current-desktop", true).toBool(); + } void setFilterCurrentDesktop(bool filter) - { m_sets.setValue("filter/current-desktop", filter); } + { + m_sets.setValue("filter/current-desktop", filter); + } bool filterCurrentScreen() const - { return m_sets.value("filter/current-screen", true).toBool(); } + { + return m_sets.value("filter/current-screen", true).toBool(); + } void setFilterCurrentScreen(bool filter) - { m_sets.setValue("filter/current-screen", filter); } + { + m_sets.setValue("filter/current-screen", filter); + } bool customFontSizeEnabled() const - { return m_sets.value("appearance/enable-font-size", 0).toBool(); } + { + return m_sets.value("appearance/enable-font-size", 0).toBool(); + } void setCustomFontSizeEnabled(bool enable) - { m_sets.setValue("appearance/enable-font-size", enable); } + { + m_sets.setValue("appearance/enable-font-size", enable); + } int customFontSize() const - { return m_sets.value("appearance/font-size", 0).toInt();} + { + return m_sets.value("appearance/font-size", 0).toInt(); + } void setCustomFontSize(int size) - { m_sets.setValue("appearance/font-size", size);} + { + m_sets.setValue("appearance/font-size", size); + } void sync() - { m_sets.sync(); } + { + m_sets.sync(); + } + private: - Settings(): - m_sets("lxqt", "app-switcher") - {} + Settings() + : m_sets("lxqt", "app-switcher") + { + } + private: QSettings m_sets; };