-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bd033d
commit 123809c
Showing
26 changed files
with
1,069 additions
and
945 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
258 changes: 150 additions & 108 deletions
258
qmlboxmodel/resources/qml/DefaultStyle.qml → ...mlboxmodel/resources/qml/DefaultStyle.qml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import QtQuick | ||
import Qt5Compat.GraphicalEffects | ||
import QtQuick.Window 2.2 // Screen.devicePixelRatio | ||
|
||
MouseArea { | ||
id: mouseArea | ||
hoverEnabled: true | ||
property alias iconColor: gearcolor.color | ||
property bool busy: false | ||
|
||
Image { | ||
id: gearmask | ||
anchors.fill: parent | ||
smooth: true | ||
source: "qrc:gear.svg" | ||
sourceSize.width: width * Screen.devicePixelRatio | ||
sourceSize.height: height * Screen.devicePixelRatio | ||
visible: false | ||
} | ||
|
||
Rectangle { | ||
id: gearcolor | ||
anchors.fill: parent | ||
visible: false | ||
} | ||
|
||
OpacityMask { | ||
id: gear | ||
anchors.fill: parent | ||
smooth: true | ||
opacity: mouseArea.containsMouse || busy ? 1 : 0 | ||
Behavior on opacity { NumberAnimation{} } | ||
cached: true | ||
source: gearcolor | ||
maskSource: gearmask | ||
RotationAnimator on rotation { | ||
loops: Animation.Infinite; | ||
from: 0; to: 360 | ||
duration: 4000 | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
// Copyright (c) 2023-2024 Manuel Schneider | ||
|
||
#include "plugin.h" | ||
#include "ui_configwidget.h" | ||
|
||
namespace { | ||
static const char* K_WND_POS = "window_position"; | ||
} | ||
|
||
Plugin::Plugin() : qml_interface_(this), window(qml_interface_) | ||
{ | ||
auto s = settings(); | ||
restore_always_on_top(s); | ||
restore_clear_on_hide(s); | ||
restore_display_system_shadow(s); | ||
restore_follow_mouse(s); | ||
restore_hide_on_close(s); | ||
restore_hide_on_focus_loss(s); | ||
restore_show_centered(s); | ||
|
||
s = state(); | ||
window.setPosition(s->value(K_WND_POS).toPoint()); | ||
|
||
connect(&window, &Window::inputChanged, this, &Plugin::inputChanged); | ||
connect(&window, &Window::visibleChanged, this, &Plugin::visibleChanged); | ||
} | ||
|
||
Plugin::~Plugin() | ||
{ | ||
state()->setValue(K_WND_POS, window.position()); | ||
} | ||
|
||
bool Plugin::isVisible() const { return window.isVisible(); } | ||
|
||
void Plugin::setVisible(bool visible) { window.setVisible(visible); } | ||
|
||
QString Plugin::input() const { return window.input(); } | ||
|
||
void Plugin::setInput(const QString &input) { window.setInput(input); } | ||
|
||
unsigned long long Plugin::winId() const { return window.winId(); } | ||
|
||
QWidget* Plugin::createFrontendConfigWidget() | ||
{ | ||
auto *w = new QWidget; | ||
Ui::ConfigWidget ui; | ||
ui.setupUi(w); | ||
|
||
ALBERT_PLUGIN_PROPERTY_CONNECT(this, always_on_top, ui.checkBox_onTop, setChecked, toggled) | ||
ALBERT_PLUGIN_PROPERTY_CONNECT(this, clear_on_hide, ui.checkBox_clearOnHide, setChecked, toggled) | ||
ALBERT_PLUGIN_PROPERTY_CONNECT(this, display_system_shadow, ui.checkBox_systemShadow, setChecked, toggled) | ||
ALBERT_PLUGIN_PROPERTY_CONNECT(this, follow_mouse, ui.checkBox_followMouse, setChecked, toggled) | ||
ALBERT_PLUGIN_PROPERTY_CONNECT(this, hide_on_close, ui.checkBox_hideOnClose, setChecked, toggled) | ||
ALBERT_PLUGIN_PROPERTY_CONNECT(this, hide_on_focus_loss, ui.checkBox_hideOnFocusOut, setChecked, toggled) | ||
ALBERT_PLUGIN_PROPERTY_CONNECT(this, show_centered, ui.checkBox_center, setChecked, toggled) | ||
|
||
// Themes | ||
|
||
// auto fillThemesCheckBox = [this, cb=ui.comboBox_themes](){ | ||
// QSignalBlocker b(cb); | ||
// cb->clear(); | ||
// QStandardItemModel *model = qobject_cast<QStandardItemModel*>(cb->model()); // safe, see docs | ||
|
||
// // Add disabled placeholder item | ||
// auto *item = new QStandardItem; | ||
// item->setText("Choose theme..."); | ||
// item->setEnabled(false); | ||
// model->appendRow(item); | ||
|
||
// cb->insertSeparator(1); | ||
|
||
// // Add themes | ||
// for (const QFileInfo &fi : availableThemes()){ | ||
// item = new QStandardItem; | ||
// item->setText(fi.baseName()); | ||
// item->setToolTip(fi.absoluteFilePath()); | ||
// model->appendRow(item); | ||
// } | ||
// }; | ||
|
||
// fillThemesCheckBox(); | ||
|
||
// connect(ui.comboBox_themes, &QComboBox::currentIndexChanged, | ||
// this, [this, cb=ui.comboBox_themes](int i){ | ||
// auto theme_file_name = cb->model()->index(i,0).data(Qt::ToolTipRole).toString(); | ||
// applyTheme(theme_file_name); | ||
// }); | ||
|
||
// connect(ui.toolButton_propertyEditor, &QToolButton::clicked, this, [this, w](){ | ||
// PropertyEditor *pe = new PropertyEditor(this, w); | ||
// pe->setWindowModality(Qt::WindowModality::WindowModal); | ||
// pe->show(); | ||
// }); | ||
|
||
// connect(ui.toolButton_save, &QToolButton::clicked, this, [this, w, fillThemesCheckBox](){ | ||
// if (auto text = QInputDialog::getText(w, qApp->applicationDisplayName(), "Theme name:"); !text.isNull()){ | ||
// if (text.isEmpty()) | ||
// QMessageBox::warning(w, qApp->applicationDisplayName(), "Theme name must not be empty."); | ||
// else if (auto dir = configDir(); dir.exists(text+".theme")) | ||
// QMessageBox::warning(w, qApp->applicationDisplayName(), "Theme already exists."); | ||
// else{ | ||
// saveThemeAsFile(dir.filePath(text)); | ||
// fillThemesCheckBox(); | ||
// } | ||
// } | ||
// }); | ||
|
||
|
||
return w; | ||
} | ||
|
||
void Plugin::setQuery(albert::Query *query) { qml_interface_.setQuery(query); } | ||
|
||
bool Plugin::always_on_top() const | ||
{ return window.flags() & Qt::WindowStaysOnTopHint; } | ||
|
||
void Plugin::set_always_on_top_(bool value) | ||
{ window.setFlags(window.flags().setFlag(Qt::WindowStaysOnTopHint, value)); } | ||
|
||
bool Plugin::display_system_shadow() const | ||
{ return !window.flags().testFlag(Qt::NoDropShadowWindowHint); } | ||
|
||
void Plugin::set_display_system_shadow_(bool value) | ||
{ window.setFlags(window.flags().setFlag(Qt::NoDropShadowWindowHint, !value)); } | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) 2023-2024 Manuel Schneider | ||
|
||
#pragma once | ||
#include "albert/extension/frontend/frontend.h" | ||
#include "albert/plugin.h" | ||
#include "qmlinterface.h" | ||
#include "window.h" | ||
#include <QSettings> | ||
|
||
class Plugin : public albert::Frontend, public albert::PluginInstance | ||
{ | ||
Q_OBJECT | ||
ALBERT_PLUGIN | ||
|
||
public: | ||
|
||
Plugin(); | ||
~Plugin(); | ||
|
||
// albert::Frontend | ||
bool isVisible() const override; | ||
void setVisible(bool visible) override; | ||
QString input() const override; | ||
void setInput(const QString&) override; | ||
unsigned long long winId() const override; | ||
QWidget* createFrontendConfigWidget() override; | ||
void setQuery(albert::Query *query) override; | ||
|
||
protected: | ||
|
||
QmlInterface qml_interface_; | ||
Window window; | ||
|
||
ALBERT_PLUGIN_PROPERTY_BASE(bool, always_on_top, true) | ||
bool always_on_top() const; | ||
void set_always_on_top_(bool value); | ||
ALBERT_PLUGIN_PROPERTY_MEMBER(bool, clear_on_hide, window.clear_on_hide, true) | ||
ALBERT_PLUGIN_PROPERTY_BASE(bool, display_system_shadow, true) | ||
bool display_system_shadow() const; | ||
void set_display_system_shadow_(bool value); | ||
ALBERT_PLUGIN_PROPERTY_MEMBER(bool, follow_mouse, window.follow_mouse, true) | ||
ALBERT_PLUGIN_PROPERTY_MEMBER(bool, hide_on_close, window.hide_on_close, true) | ||
ALBERT_PLUGIN_PROPERTY_MEMBER(bool, hide_on_focus_loss, window.hide_on_focus_loss, true) | ||
ALBERT_PLUGIN_PROPERTY_MEMBER(bool, show_centered, window.show_centered, true) | ||
|
||
}; | ||
|
||
|
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) 2023-2024 Manuel Schneider | ||
|
||
#include "albert/albert.h" | ||
#include "albert/extension/frontend/query.h" | ||
#include "albert/logging.h" | ||
#include "plugin.h" | ||
#include "qmlinterface.h" | ||
|
||
#include <QStringListModel> | ||
using namespace albert; | ||
|
||
QmlInterface::QmlInterface(Plugin *plugin) : plugin_(plugin) { } | ||
|
||
void QmlInterface::showSettings() | ||
{ | ||
plugin_->setVisible(false); | ||
albert::showSettings(); | ||
} | ||
|
||
QObject *QmlInterface::currentQuery() { return currentQuery_; } | ||
|
||
QString QmlInterface::kcString(int kc) { return QKeySequence(kc).toString(); } | ||
|
||
void QmlInterface::debug(QString m) { DEBG << m; } | ||
void QmlInterface::info(QString m) { INFO << m; } | ||
void QmlInterface::warning(QString m) { WARN << m; } | ||
void QmlInterface::critical(QString m) { CRIT << m; } | ||
|
||
QAbstractListModel *QmlInterface::createStringListModel(const QStringList &action_names) const | ||
{ return new QStringListModel(action_names); } | ||
|
||
void QmlInterface::setQuery(Query *q) | ||
{ | ||
CRIT << "QmlInterface::setQuery"; | ||
|
||
if(currentQuery_) | ||
disconnect(currentQuery_, &Query::finished, | ||
this, &QmlInterface::currentQueryFinished); | ||
|
||
CRIT << "das"; | ||
|
||
// important for qml ownership determination | ||
if (q) | ||
q->setParent(this); | ||
CRIT << "noch"; | ||
|
||
currentQuery_ = q; | ||
emit currentQueryChanged(); | ||
CRIT << "geschafft"; | ||
|
||
|
||
if (q) | ||
{ | ||
if (q->isFinished()) | ||
emit currentQueryFinished(); | ||
else | ||
connect(q, &Query::finished, this, &QmlInterface::currentQueryFinished); | ||
} | ||
|
||
CRIT << "!"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) 2023-2024 Manuel Schneider | ||
|
||
#pragma once | ||
#include <QAbstractListModel> | ||
#include <QObject> | ||
#include <QString> | ||
class Plugin; | ||
namespace albert { class Query; } | ||
|
||
|
||
class QmlInterface : public QObject | ||
{ | ||
Q_OBJECT | ||
Q_PROPERTY(QObject* currentQuery_ READ currentQuery NOTIFY currentQueryChanged) | ||
|
||
public: | ||
QmlInterface(Plugin *plugin); | ||
|
||
Q_INVOKABLE void showSettings(); | ||
Q_INVOKABLE QObject *currentQuery(); | ||
Q_INVOKABLE QString kcString(int kc); | ||
|
||
Q_INVOKABLE void debug(QString m); | ||
Q_INVOKABLE void info(QString m); | ||
Q_INVOKABLE void warning(QString m); | ||
Q_INVOKABLE void critical(QString m); | ||
|
||
Q_INVOKABLE QAbstractListModel *createStringListModel(const QStringList &action_names) const; | ||
|
||
void setQuery(albert::Query *q); | ||
|
||
private: | ||
Plugin *plugin_; | ||
albert::Query *currentQuery_; | ||
|
||
signals: | ||
void currentQueryChanged(); | ||
void currentQueryFinished(); // convenience signal to avoid the boilerplate in qml | ||
|
||
}; | ||
|
Oops, something went wrong.