Add actions.
This commit is contained in:
parent
f99ce401e6
commit
29e8968938
|
@ -138,6 +138,7 @@ QString escapeHtml(const QString & str) {
|
|||
|
||||
void DetailWidget::setWidgetInfo(const QString &plugin_name, const SearchPluginIface::ResultInfo &info)
|
||||
{
|
||||
clearLayout(m_descFrameLyt);
|
||||
m_iconLabel->setPixmap(info.icon.pixmap(info.icon.actualSize(ICON_SIZE)));
|
||||
m_iconLabel->show();
|
||||
QFontMetrics fontMetrics = m_nameLabel->fontMetrics();
|
||||
|
@ -147,6 +148,7 @@ void DetailWidget::setWidgetInfo(const QString &plugin_name, const SearchPluginI
|
|||
m_pluginLabel->setText(plugin_name);
|
||||
m_nameFrame->show();
|
||||
m_line_1->show();
|
||||
|
||||
if (info.description.length() > 0) {
|
||||
//NEW_TODO 样式待优化
|
||||
clearLayout(m_descFrameLyt);
|
||||
|
@ -162,10 +164,10 @@ void DetailWidget::setWidgetInfo(const QString &plugin_name, const SearchPluginI
|
|||
m_line_2->show();
|
||||
}
|
||||
clearLayout(m_actionFrameLyt);
|
||||
// Q_FOREACH (auto action, info.actionList) {
|
||||
// ActionLabel * actionLabel = new ActionLabel(action, info.key, plugin_name, m_actionFrame);
|
||||
// m_actionFrameLyt->addWidget(actionLabel);
|
||||
// }
|
||||
Q_FOREACH (SearchPluginIface::Actioninfo actioninfo, SearchPluginManager::getInstance()->getPlugin(plugin_name)->getActioninfo(info.type)) {
|
||||
ActionLabel * actionLabel = new ActionLabel(actioninfo.displayName, info.actionKey, actioninfo.actionkey, plugin_name, info.type, m_actionFrame);
|
||||
m_actionFrameLyt->addWidget(actionLabel);
|
||||
}
|
||||
m_actionFrame->show();
|
||||
}
|
||||
|
||||
|
@ -248,7 +250,7 @@ void DetailWidget::paintEvent(QPaintEvent * event)
|
|||
|
||||
void DetailWidget::clearLayout(QLayout *layout)
|
||||
{
|
||||
if(! layout) return;
|
||||
if(!layout) return;
|
||||
QLayoutItem * child;
|
||||
while((child = layout->takeAt(0)) != 0) {
|
||||
if(child->widget()) {
|
||||
|
@ -259,11 +261,13 @@ void DetailWidget::clearLayout(QLayout *layout)
|
|||
child = NULL;
|
||||
}
|
||||
|
||||
ActionLabel::ActionLabel(const QString &action, const QString &key, const QString &plugin, QWidget *parent) : QLabel(parent)
|
||||
ActionLabel::ActionLabel(const QString &action, const QString &key, const int &ActionKey, const QString &pluginId, const int type, QWidget *parent) : QLabel(parent)
|
||||
{
|
||||
m_action = action;
|
||||
m_key = key;
|
||||
m_plugin = plugin;
|
||||
m_actionKey = ActionKey;
|
||||
m_type = type;
|
||||
m_pluginId = pluginId;
|
||||
this->initUi();
|
||||
this->installEventFilter(this);
|
||||
}
|
||||
|
@ -287,10 +291,10 @@ bool ActionLabel::eventFilter(QObject *watched, QEvent *event)
|
|||
this->setForegroundRole(QPalette::Dark);
|
||||
return true;
|
||||
} else if(event->type() == QEvent::MouseButtonRelease) {
|
||||
SearchPluginIface *plugin = SearchPluginManager::getInstance()->getPlugin(m_plugin);
|
||||
// if (plugin)
|
||||
// plugin->openAction(m_action, m_key);
|
||||
// else
|
||||
SearchPluginIface *plugin = SearchPluginManager::getInstance()->getPlugin(m_pluginId);
|
||||
if (plugin)
|
||||
plugin->openAction(m_actionKey, m_key, m_type);
|
||||
else
|
||||
qWarning()<<"Get plugin failed!";
|
||||
this->setForegroundRole(QPalette::Light);
|
||||
return true;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
#include "result-view.h"
|
||||
#include "plugininterface/search-plugin-iface.h"
|
||||
#include "search-plugin-iface.h"
|
||||
|
||||
namespace Zeeker {
|
||||
class ResultArea : public QScrollArea
|
||||
|
@ -100,13 +100,15 @@ class ActionLabel : public QLabel
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ActionLabel(const QString &action, const QString &key, const QString &plugin, QWidget *parent = nullptr);
|
||||
ActionLabel(const QString &action, const QString &key, const int &ActionKey, const QString &pluginId, const int type = 0, QWidget *parent = nullptr);
|
||||
~ActionLabel() = default;
|
||||
private:
|
||||
void initUi();
|
||||
QString m_action;
|
||||
QString m_key;
|
||||
QString m_plugin;
|
||||
int m_actionKey;
|
||||
int m_type = 0;
|
||||
QString m_pluginId;
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *, QEvent *);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#include "search-page.h"
|
||||
using namespace Zeeker;
|
||||
|
||||
#define RESULT_WIDTH 240
|
||||
#define RESULT_WIDTH 298
|
||||
#define DETAIL_WIDTH 400
|
||||
|
||||
SearchPage::SearchPage(QWidget *parent) : QWidget(parent)
|
||||
|
|
|
@ -42,12 +42,12 @@
|
|||
#define UKUI_SEARCH_SCHEMAS "org.ukui.search.settings"
|
||||
#define SEARCH_METHOD_KEY "indexSearch"
|
||||
#define WEB_ENGINE_KEY "webEngine"
|
||||
#define WINDOW_WIDTH 640
|
||||
#define WINDOW_HEIGHT 590
|
||||
#define WINDOW_WIDTH 680
|
||||
#define WINDOW_HEIGHT 600
|
||||
#define TITLE_HEIGHT 40
|
||||
#define WINDOW_ICON_SIZE 24
|
||||
#define SETTING_BTN_SIZE 30
|
||||
#define SEARCH_BAR_SIZE 44
|
||||
#define SEARCH_BAR_SIZE 48
|
||||
#define ASK_INDEX_TIME 5*1000
|
||||
#define RESEARCH_TIME 10*1000
|
||||
|
||||
|
|
|
@ -12,6 +12,13 @@ void ResultViewDelegate::setSearchKeyword(const QString ®FindKeyWords)
|
|||
m_regFindKeyWords = regFindKeyWords;
|
||||
}
|
||||
|
||||
QSize ResultViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
{
|
||||
QSize size = QStyledItemDelegate::sizeHint(option,index);
|
||||
size.setHeight(size.height() + 10);
|
||||
return size;
|
||||
}
|
||||
|
||||
void ResultViewDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const {
|
||||
QStyleOptionViewItemV4 optionV4 = option;
|
||||
initStyleOption(&optionV4, index);
|
||||
|
@ -30,7 +37,7 @@ void ResultViewDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
|
|||
ctx.palette.setColor(QPalette::Text, optionV4.palette.color(QPalette::Active, QPalette::HighlightedText));
|
||||
|
||||
QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &optionV4);
|
||||
textRect.adjust(0, -5, 0, 0);
|
||||
textRect.adjust(0, 0, 0, 0);
|
||||
painter->save();
|
||||
painter->translate(textRect.topLeft());
|
||||
painter->setClipRect(textRect.translated(-textRect.topLeft()));
|
||||
|
|
|
@ -35,6 +35,8 @@ public:
|
|||
explicit ResultViewDelegate(QObject *parent = nullptr);
|
||||
~ResultViewDelegate() = default;
|
||||
void setSearchKeyword(const QString &);
|
||||
protected:
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||
private:
|
||||
QString m_regFindKeyWords = 0;
|
||||
void paint(QPainter *, const QStyleOptionViewItem &, const QModelIndex &) const override;
|
||||
|
|
|
@ -104,11 +104,11 @@ bool AppSearchPlugin::addPanelShortcut(const QString& path) {
|
|||
if(iface.isValid()) {
|
||||
QDBusReply<bool> isExist = iface.call("CheckIfExist", path);
|
||||
if(isExist) {
|
||||
qWarning() << "qDebug: Add shortcut to panel failed, because it is already existed!";
|
||||
qWarning() << "Add shortcut to panel failed, because it is already existed!";
|
||||
return false;
|
||||
}
|
||||
QDBusReply<QVariant> ret = iface.call("AddToTaskbar", path);
|
||||
qDebug() << "qDebug: Add shortcut to panel successed!";
|
||||
qDebug() << "Add shortcut to panel successed!";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue