diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 841e5545..a8956631 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -115,6 +115,7 @@ if (MACOS OR LINUX) ckb-next PRIVATE animadddialog.cpp + animdetailsdialog.cpp animscript.cpp animsettingdialog.cpp autorun.cpp @@ -158,6 +159,7 @@ if (MACOS OR LINUX) rlistwidget.cpp settingswidget.cpp animadddialog.h + animdetailsdialog.h animscript.h animsettingdialog.h autorun.h @@ -201,6 +203,7 @@ if (MACOS OR LINUX) rlistwidget.h settingswidget.h animadddialog.ui + animdetailsdialog.ui animsettingdialog.ui ckbupdaterwidget.ui extrasettingswidget.ui diff --git a/src/gui/animdetailsdialog.cpp b/src/gui/animdetailsdialog.cpp new file mode 100644 index 00000000..e8de74e5 --- /dev/null +++ b/src/gui/animdetailsdialog.cpp @@ -0,0 +1,27 @@ +#include "animdetailsdialog.h" +#include "ui_animdetailsdialog.h" +#include + +AnimDetailsDialog::AnimDetailsDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::AnimDetailsDialog) +{ + ui->setupUi(this); + foreach(const AnimScript* script, AnimScript::list()){ + int row = ui->animTable->rowCount(); + ui->animTable->insertRow(row); + ui->animTable->setItem(row, 0, new QTableWidgetItem(script->name())); + ui->animTable->setItem(row, 1, new QTableWidgetItem(script->path())); + ui->animTable->setItem(row, 2, new QTableWidgetItem(script->version())); + ui->animTable->setItem(row, 3, new QTableWidgetItem(script->author())); + ui->animTable->setItem(row, 4, new QTableWidgetItem(script->year())); + ui->animTable->setItem(row, 5, new QTableWidgetItem(script->license())); + ui->animTable->setItem(row, 6, new QTableWidgetItem(QTextDocumentFragment::fromHtml(script->description()).toPlainText())); + } + ui->animTable->resizeColumnsToContents(); +} + +AnimDetailsDialog::~AnimDetailsDialog() +{ + delete ui; +} diff --git a/src/gui/animdetailsdialog.h b/src/gui/animdetailsdialog.h new file mode 100644 index 00000000..10a4bf50 --- /dev/null +++ b/src/gui/animdetailsdialog.h @@ -0,0 +1,23 @@ +#ifndef ANIMDETAILSDIALOG_H +#define ANIMDETAILSDIALOG_H + +#include +#include "animscript.h" + +namespace Ui { +class AnimDetailsDialog; +} + +class AnimDetailsDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AnimDetailsDialog(QWidget *parent = nullptr); + ~AnimDetailsDialog(); + +private: + Ui::AnimDetailsDialog *ui; +}; + +#endif // ANIMDETAILSDIALOG_H diff --git a/src/gui/animdetailsdialog.ui b/src/gui/animdetailsdialog.ui new file mode 100644 index 00000000..a8bb2c33 --- /dev/null +++ b/src/gui/animdetailsdialog.ui @@ -0,0 +1,130 @@ + + + AnimDetailsDialog + + + + 0 + 0 + 750 + 550 + + + + + 750 + 350 + + + + Loaded Animations + + + + + + QAbstractScrollArea::AdjustToContentsOnFirstShow + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::ScrollPerPixel + + + false + + + 7 + + + true + + + + Name + + + + + Path + + + + + Version + + + + + Author + + + + + Year + + + + + License + + + + + Descripton + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + AnimDetailsDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + AnimDetailsDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/gui/animscript.cpp b/src/gui/animscript.cpp index a8c4693f..954420dc 100644 --- a/src/gui/animscript.cpp +++ b/src/gui/animscript.cpp @@ -6,6 +6,7 @@ #include #include #include "animscript.h" +#include QHash AnimScript::scripts; @@ -27,24 +28,47 @@ AnimScript::~AnimScript(){ } } -QString AnimScript::path(){ - return QString(CKB_NEXT_ANIMATIONS_PATH); +QStringList AnimScript::paths(){ + QStringList list(CKB_NEXT_ANIMATIONS_PATH); + // Path for when running the GUI from the build dir +#ifdef Q_OS_LINUX + QString appDirPath = QCoreApplication::applicationDirPath(); + if(!appDirPath.startsWith("/usr")) + list << appDirPath; +#endif + list << QDir::toNativeSeparators(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation).append("/ckb-next/animations")); + return list; } void AnimScript::scan(){ - QDir dir(path()); + // Clear old animations foreach(AnimScript* script, scripts) delete script; scripts.clear(); - foreach(QString file, dir.entryList(QDir::Files | QDir::Executable)){ - AnimScript* script = new AnimScript(qApp, dir.absoluteFilePath(file)); - if(script->load() && !scripts.contains(script->_info.guid) && script->presets().count()){ - scripts[script->_info.guid] = script; + + // Search for animations in all directories, in reverse + // This is done so that the user animation dir takes priority over the system one + for(int i = paths().length() - 1; i >= 0; i--){ + QDir dir(paths().at(i)); + + if(!dir.exists()) continue; + + foreach(QString file, dir.entryList(QDir::Files | QDir::Executable)){ +#ifdef Q_OS_LINUX + // Ignore the GUI and daemon binaries if loading animations from the build dir + if(file.endsWith("ckb-next") || file.endsWith("ckb-next-daemon")) + continue; +#endif + AnimScript* script = new AnimScript(qApp, dir.absoluteFilePath(file)); + if(script->load() && !scripts.contains(script->_info.guid) && script->presets().count()){ + scripts[script->_info.guid] = script; + continue; + } + if(!script->presets().count()) + qWarning() << script->name() << "has no default preset and will not be loaded."; + delete script; } - if(!script->presets().count()) - qWarning() << script->name() << "has no default preset and will not be loaded."; - delete script; } } diff --git a/src/gui/animscript.h b/src/gui/animscript.h index 0c248100..313636aa 100644 --- a/src/gui/animscript.h +++ b/src/gui/animscript.h @@ -47,7 +47,7 @@ public: }; // Global animation path - static QString path(); + static QStringList paths(); // Scan the animation path for scripts static void scan(); // Loaded script count and alphabetical list @@ -67,6 +67,7 @@ public: inline bool hasKeypress() const { return _info.kpMode != KP_NONE; } inline const QStringList& presets() const { return _presets; } inline const PresetValue& preset(int index) const { return _presetValues[index]; } + inline const QString& path() const { return _path; } // Parameters, in the order they were given inline QListIterator paramIterator() const { return _info.params; } diff --git a/src/gui/extrasettingswidget.cpp b/src/gui/extrasettingswidget.cpp index 3bfcdcfc..2bc3dc9a 100644 --- a/src/gui/extrasettingswidget.cpp +++ b/src/gui/extrasettingswidget.cpp @@ -3,6 +3,7 @@ #include "kb.h" #include "mainwindow.h" #include "ckbsettings.h" +#include "animdetailsdialog.h" // KbLight static int lastSharedDimming = -2; @@ -61,7 +62,7 @@ ExtraSettingsWidget::ExtraSettingsWidget(QWidget *parent) : ui->trayBox->setChecked(settings.value("SuppressTrayIcon").toBool()); // Update animation info - ui->animPathLabel->setText(AnimScript::path()); + ui->animPathLabel->setText(AnimScript::paths().join('\n')); on_animScanButton_clicked(); /// Read Macro Delay setting, update UI and Kb-internal flag @@ -162,3 +163,10 @@ void ExtraSettingsWidget::on_previewBox_clicked(bool checked) { CkbSettings::set("Program/DisablePreviewOnFocusLoss", checked); } + +void ExtraSettingsWidget::on_detailsBtn_clicked() +{ + AnimDetailsDialog* dlg = new AnimDetailsDialog(this); + dlg->setAttribute(Qt::WA_DeleteOnClose, true); + dlg->exec(); +} diff --git a/src/gui/extrasettingswidget.h b/src/gui/extrasettingswidget.h index a1635f3f..f5114f30 100644 --- a/src/gui/extrasettingswidget.h +++ b/src/gui/extrasettingswidget.h @@ -30,6 +30,8 @@ private slots: void on_startDelayBox_clicked(bool checked); void on_previewBox_clicked(bool checked); + void on_detailsBtn_clicked(); + private: Ui::ExtraSettingsWidget *ui; }; diff --git a/src/gui/extrasettingswidget.ui b/src/gui/extrasettingswidget.ui index 7cf4dbd6..4e842f8f 100644 --- a/src/gui/extrasettingswidget.ui +++ b/src/gui/extrasettingswidget.ui @@ -29,8 +29,74 @@ 6 - - + + + + By default, the same brightness level will be applied to all profiles and all devices. Enable this to store it with the lighting mode instead. + + + Set brightness per-mode + + + + + + + + 75 + true + + + + Behavior + + + + + + + + 75 + true + + + + OS X tweaks + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + The tray icon will not be displayed. The application will still run in the background; re-launch the app to see the GUI again. + + + Hide tray icon + + + + + + + Qt::Horizontal + + + + + Qt::Horizontal @@ -52,23 +118,10 @@ - - - - Try this if you're having problems with mouse movement. - + + - Disable mouse acceleration - - - - - - - May improve appearance on some keyboards. - - - Use spatial dithering to simulate extra color resolution + Frame rate (FPS): @@ -88,46 +141,100 @@ - - + + + + + + /path/to/animations + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Qt::Horizontal + + + QSizePolicy::MinimumExpanding + + + + 10 + 20 + + + + + + + + 3 + + + + + + 0 + 0 + + + + 0 animations found + + + Qt::AlignCenter + + + + + + + + + Re-scan + + + + + + + Details + + + + + + + + + + + - Disable animated preview when ckb-next is not in focus + Location: - - false + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + 0 - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 75 - true - + + + + Try this if you're having problems with mouse movement. - Animation scripts + Disable mouse acceleration @@ -147,55 +254,6 @@ - - - - 5 - - - 60 - - - 30 - - - - - - - When using macros with strings longer than 25 chars, some OS may lose characters (e.g. Mint 17.2). Select to prevent that bug. - - - Use delay for very long macros - - - - - - - true - - - - 8 - true - - - - Enabling per-mode brightness will disable scrolling on the tray icon to change the brightness level - - - - - - - By default, the same brightness level will be applied to all profiles and all devices. Enable this to store it with the lighting mode instead. - - - Set brightness per-mode - - - @@ -209,29 +267,6 @@ - - - - Try this if you're having problems with the scroll wheel. - - - Disable scroll acceleration - - - - - - - - 75 - true - - - - Behavior - - - @@ -245,76 +280,6 @@ - - - - Qt::Horizontal - - - - - - - - - /path/to/animations - - - - - - - - 0 - 0 - - - - 0 animations found - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Re-scan - - - - - - - - - - 75 - true - - - - OS X tweaks - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - @@ -372,27 +337,86 @@ - - + + - Location: + Disable animated preview when ckb-next is not in focus + + + false - - + + + + When using macros with strings longer than 25 chars, some OS may lose characters (e.g. Mint 17.2). Select to prevent that bug. + + + Use delay for very long macros + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + Qt::Horizontal - - + + - The tray icon will not be displayed. The application will still run in the background; re-launch the app to see the GUI again. + May improve appearance on some keyboards. - Hide tray icon + Use spatial dithering to simulate extra color resolution + + + + + + + Try this if you're having problems with the scroll wheel. + + + Disable scroll acceleration + + + + + + + Qt::Horizontal + + + + + + + + 75 + true + + + + Animation scripts @@ -403,10 +427,32 @@ - - + + + + 5 + + + 60 + + + 30 + + + + + + + true + + + + 8 + true + + - Frame rate (FPS): + Enabling per-mode brightness will disable scrolling on the tray icon to change the brightness level @@ -415,7 +461,6 @@ trayBox brightnessBox - animScanButton fpsBox ditherBox delayBox