aboutsummaryrefslogtreecommitdiff
path: root/src-qt5
diff options
context:
space:
mode:
Diffstat (limited to 'src-qt5')
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp7
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h2
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp83
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h12
-rw-r--r--src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.ui27
5 files changed, 120 insertions, 11 deletions
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp
index a742384d..3a0493a3 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.cpp
@@ -64,7 +64,8 @@ ItemWidget::ItemWidget(QWidget *parent, QString itemPath, QString type, bool gob
}else if(LUtils::imageExtensions().contains(itemPath.section("/",-1).section(".",-1).toLower()) ){
icon->setPixmap( QIcon(itemPath).pixmap(64,64) );
}else{
- icon->setPixmap( LXDG::findMimeIcon(itemPath.section("/",-1)).pixmap(64,64) );
+ if( LUtils::isValidBinary(itemPath) ){ icon->setPixmap( LXDG::findIcon(type, "application-x-executable").pixmap(64,64) ); }
+ else{ icon->setPixmap( LXDG::findMimeIcon(itemPath.section("/",-1)).pixmap(64,64) ); }
}
name->setText( itemPath.section("/",-1) ); //this->fontMetrics().elidedText(itemPath.section("/",-1), Qt::ElideRight, TEXTCUTOFF) );
text = itemPath.section("/",-1) ;
@@ -119,6 +120,10 @@ ItemWidget::ItemWidget(QWidget *parent, XDGDesktop item) : QFrame(parent){
ItemWidget::~ItemWidget(){
}
+void ItemWidget::triggerItem(){
+ ItemClicked();
+}
+
void ItemWidget::createWidget(){
//Initialize the widgets
gooditem = true;
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h
index 0f24cec4..8190de43 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/ItemWidget.h
@@ -40,6 +40,8 @@ public:
bool gooditem;
+ void triggerItem(); //trigger this item - just as if it was clicked on
+
private:
QToolButton *actButton;
QMenu *contextMenu;
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
index 019f0d12..8e72030d 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.cpp
@@ -18,6 +18,10 @@
StartMenu::StartMenu(QWidget *parent) : QWidget(parent), ui(new Ui::StartMenu){
ui->setupUi(this); //load the designer file
this->setMouseTracking(true);
+ searchTimer = new QTimer(this);
+ searchTimer->setInterval(300); //~1/3 second
+ searchTimer->setSingleShot(true);
+ connect(searchTimer, SIGNAL(timeout()), this, SLOT(startSearch()) );
sysapps = LSession::handle()->applicationMenu()->currentAppHash();
connect(LSession::handle()->applicationMenu(), SIGNAL(AppMenuUpdated()), this, SLOT(UpdateApps()) );
//Need to load the last used setting of the application list
@@ -122,6 +126,7 @@ void StartMenu::UpdateAll(){
void StartMenu::UpdateMenu(bool forceall){
//qDebug() << "Update Menu" << forceall;
+ ui->line_search->clear();
if(forceall){ UpdateAll(); }
//Quick update routine before the menu is made visible
//qDebug() << "update favs";
@@ -190,6 +195,66 @@ void StartMenu::SortScrollArea(QScrollArea *area){
}
}
+void StartMenu::do_search(QString search, bool force){
+ search = search.simplified(); //remove unneccesary whitespace
+ if(search == CSearch && !force){
+ //nothing new - just ensure the page is visible
+ if(ui->stackedWidget->currentWidget()!=ui->page_search ){ ui->stackedWidget->setCurrentWidget(ui->page_search); }
+ return;
+ }else if(search.isEmpty()){
+ CSearch.clear();
+ if(ui->stackedWidget->currentWidget()==ui->page_search ){ on_tool_back_clicked(); }
+ return;
+ }
+ //Got a search term - check it
+ CSearch = search; //save this for comparison later
+ qDebug() << "Search for term:" << search;
+ ClearScrollArea(ui->scroll_search);
+ topsearch.clear();
+ //Now find any items which match the search
+ QStringList found; //syntax: [<sorter>::::<mimetype>::::<filepath>]
+ QString tmp = search;
+ if(LUtils::isValidBinary(tmp)){ found << "0::::application/x-executable::::"+tmp; }
+ QList<XDGDesktop> apps = sysapps->value("All");
+ for(int i=0; i<apps.length(); i++){
+ int priority = -1;
+ if(apps[i].name.toLower()==search.toLower()){ priority = 10; }
+ else if(apps[i].name.startsWith(search, Qt::CaseInsensitive)){ priority = 15; }
+ else if(apps[i].name.contains(search, Qt::CaseInsensitive)){ priority = 19; }
+ else if(apps[i].genericName.contains(search, Qt::CaseInsensitive)){ priority = 20; }
+ else if(apps[i].comment.contains(search, Qt::CaseInsensitive)){ priority = 30; }
+ //Can add other filters here later
+
+ if(priority>0){
+ found << QString::number(priority)+"::::app::::"+apps[i].filePath;
+ }
+ }
+ found.sort(Qt::CaseInsensitive); //sort by priority/type (lower numbers are higher on list)
+ qDebug() << "Sorted Items:" << found;
+ //Now add the items to the menu in order
+ for(int i=0; i<found.length(); i++){
+ if( !QFile::exists(found[i].section("::::",2,-1)) ){ continue; } //invalid favorite - skip it
+ if(topsearch.isEmpty()){ topsearch = found[i].section("::::",2,-1); }
+ ItemWidget *it = 0;
+ if( found[i].section("::::",2,-1).endsWith(".desktop")){
+ bool ok = false;
+ XDGDesktop item = LXDG::loadDesktopFile(found[i].section("::::",2,-1), ok);
+ if(ok){ ok = LXDG::checkValidity(item); }
+ if(ok){ it = new ItemWidget(ui->scroll_favs->widget(), item); }
+ }else{
+ it = new ItemWidget(ui->scroll_favs->widget(), found[i].section("::::",2,-1), found[i].section("::::",1,1) );
+ }
+ if(it==0){ continue; }
+ if(!it->gooditem){ it->deleteLater(); continue; } //invalid for some reason
+ ui->scroll_search->widget()->layout()->addWidget(it);
+ connect(it, SIGNAL(NewShortcut()), this, SLOT(UpdateFavs()) );
+ connect(it, SIGNAL(RemovedShortcut()), this, SLOT(UpdateFavs()) );
+ connect(it, SIGNAL(RunItem(QString)), this, SLOT(LaunchItem(QString)) );
+ connect(it, SIGNAL(toggleQuickLaunch(QString, bool)), this, SLOT(UpdateQuickLaunch(QString, bool)) );
+ }
+ ui->stackedWidget->setCurrentWidget(ui->page_search);
+}
+
// ========================
// PRIVATE SLOTS
// ========================
@@ -370,7 +435,8 @@ void StartMenu::UpdateFavs(){
void StartMenu::on_stackedWidget_currentChanged(int val){
QWidget *page = ui->stackedWidget->widget(val);
ui->tool_back->setVisible(page != ui->page_main);
- ui->line_search->setVisible(false); //not implemented yet
+ ui->line_search->setFocus();
+
//Now the page specific updates
if(page == ui->page_main){
if(!ui->label_status_battery->whatsThis().isEmpty()){
@@ -587,6 +653,17 @@ void StartMenu::on_combo_locale_currentIndexChanged(int){
//Search
-void StartMenu::on_line_search_editingFinished(){
-
+void StartMenu::on_line_search_textEdited(QString){
+ if(searchTimer->isActive()){ searchTimer->stop(); }
+ searchTimer->start();
+}
+
+void StartMenu::startSearch(){
+ if(!this->isVisible()){ return; } //menu closed while timer was active
+ do_search(ui->line_search->text(),false); //auto-launched
+}
+
+void StartMenu::on_line_search_returnPressed(){
+ if(topsearch.isEmpty()){ return; }
+ LaunchItem(topsearch);
}
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h
index 23aa4c07..249709a8 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.h
@@ -34,12 +34,14 @@ private:
Ui::StartMenu *ui;
QHash<QString, QList<XDGDesktop> > *sysapps;
QStringList favs;
- QString CCat; //current category
+ QString CCat, CSearch, topsearch; //current category/search
+ QTimer *searchTimer;
//Simple utility functions
void ClearScrollArea(QScrollArea *area);
void SortScrollArea(QScrollArea *area);
-
+ void do_search(QString search, bool force);
+
private slots:
void LaunchItem(QString path, bool fix = true);
@@ -88,7 +90,9 @@ private slots:
void on_combo_locale_currentIndexChanged(int);
//Search
- void on_line_search_editingFinished();
+ void on_line_search_textEdited(QString);
+ void startSearch();
+ void on_line_search_returnPressed();
signals:
void CloseMenu();
@@ -96,4 +100,4 @@ signals:
};
-#endif \ No newline at end of file
+#endif
diff --git a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.ui b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.ui
index 896f1c8b..74f61d7f 100644
--- a/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.ui
+++ b/src-qt5/core/lumina-desktop/panel-plugins/systemstart/StartMenu.ui
@@ -42,7 +42,7 @@
<item>
<widget class="QStackedWidget" name="stackedWidget">
<property name="currentIndex">
- <number>2</number>
+ <number>4</number>
</property>
<widget class="QWidget" name="page_main">
<layout class="QVBoxLayout" name="verticalLayout_2">
@@ -143,7 +143,7 @@
<x>0</x>
<y>0</y>
<width>179</width>
- <height>169</height>
+ <height>177</height>
</rect>
</property>
</widget>
@@ -439,7 +439,7 @@
<x>0</x>
<y>0</y>
<width>179</width>
- <height>280</height>
+ <height>284</height>
</rect>
</property>
</widget>
@@ -1087,6 +1087,27 @@
</item>
</layout>
</widget>
+ <widget class="QWidget" name="page_search">
+ <layout class="QVBoxLayout" name="verticalLayout_12">
+ <item>
+ <widget class="QScrollArea" name="scroll_search">
+ <property name="widgetResizable">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="scrollAreaWidgetContents_3">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>161</width>
+ <height>332</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</widget>
</item>
<item>
bgstack15