diff options
author | Ken Moore <ken@pcbsd.org> | 2014-09-19 14:22:37 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2014-09-19 14:22:37 -0400 |
commit | 6aca0b96c833bb14fbf3a90170ca861b6d1e8935 (patch) | |
tree | fd5a57c8bf7777107c3b312c1229f8ba230a3cdd /lumina-desktop/panel-plugins/userbutton/UserWidget.cpp | |
parent | Add support for detecting whether the running user has permission to shutdown... (diff) | |
download | lumina-6aca0b96c833bb14fbf3a90170ca861b6d1e8935.tar.gz lumina-6aca0b96c833bb14fbf3a90170ca861b6d1e8935.tar.bz2 lumina-6aca0b96c833bb14fbf3a90170ca861b6d1e8935.zip |
Update the appearance/functionality of the userbutton quite a bit in lumina-desktop.
1) Should now only reload the applications list if the installed apps changed recently, making the menu show up a ton faster.
2) Move the tabs over to the left side of the UI, and remove a lot of empty space.
3) Attempt to have the widget track the mouse and switch to a new tab on mouse-over instead of requiring a click (still in testing - no loss of functionality at the moment).
Diffstat (limited to 'lumina-desktop/panel-plugins/userbutton/UserWidget.cpp')
-rw-r--r-- | lumina-desktop/panel-plugins/userbutton/UserWidget.cpp | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp index 1571760b..f7a932ad 100644 --- a/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp +++ b/lumina-desktop/panel-plugins/userbutton/UserWidget.cpp @@ -9,23 +9,24 @@ #include "../../LSession.h" #include "../../AppMenu.h" -UserWidget::UserWidget(QWidget* parent) : QWidget(parent), ui(new Ui::UserWidget){ +UserWidget::UserWidget(QWidget* parent) : QTabWidget(parent), ui(new Ui::UserWidget){ ui->setupUi(this); - this->setContentsMargins(0,0,0,0); + if(parent!=0){ parent->setMouseTracking(true); } + this->setMouseTracking(true); sysapps = LSession::applicationMenu()->currentAppHash(); //get the raw info //Setup the Icons // - favorites tab - ui->tabWidget->setTabIcon(0, LXDG::findIcon("favorites","") ); - ui->tabWidget->setTabText(0,""); + this->setTabIcon(0, rotateIcon(LXDG::findIcon("favorites","")) ); + this->setTabText(0,""); // - apps tab - ui->tabWidget->setTabIcon(1, LXDG::findIcon("system-run","") ); - ui->tabWidget->setTabText(1,""); + this->setTabIcon(1, rotateIcon(LXDG::findIcon("system-run","")) ); + this->setTabText(1,""); // - home tab - ui->tabWidget->setTabIcon(2, LXDG::findIcon("user-home","") ); - ui->tabWidget->setTabText(2,""); + this->setTabIcon(2, rotateIcon(LXDG::findIcon("user-home","")) ); + this->setTabText(2,""); // - config tab - ui->tabWidget->setTabIcon(3, LXDG::findIcon("preferences-system","") ); - ui->tabWidget->setTabText(3,""); + this->setTabIcon(3, rotateIcon(LXDG::findIcon("preferences-system","")) ); + this->setTabText(3,""); ui->tool_fav_apps->setIcon( LXDG::findIcon("system-run","") ); ui->tool_fav_dirs->setIcon( LXDG::findIcon("folder","") ); ui->tool_fav_files->setIcon( LXDG::findIcon("document-multiple","") ); @@ -75,7 +76,7 @@ UserWidget::UserWidget(QWidget* parent) : QWidget(parent), ui(new Ui::UserWidget }else{ ui->tool_qtconfig->setVisible(false); } - lastUpdate = QDateTime::currentDateTime().addSecs(-30); //make sure it refreshes + lastUpdate = QDateTime(); //make sure it refreshes QTimer::singleShot(10,this, SLOT(UpdateMenu())); //make sure to load this once after initialization } @@ -97,19 +98,28 @@ void UserWidget::ClearScrollArea(QScrollArea *area){ area->widget()->setLayout(layout); } +QIcon UserWidget::rotateIcon(QIcon ico){ + //Rotate the given icon to appear vertical in the tab widget + QPixmap pix = ico.pixmap(32,32); + QTransform tran; + tran.rotate(+90); //For tabs on the left/West + pix = pix.transformed(tran); + ico = QIcon(pix); + return ico; +} + //============ // PRIVATE SLOTS //============ void UserWidget::UpdateMenu(){ - if(QDateTime::currentDateTime() > lastUpdate.addSecs(30)){ - //Only re-arrange/reload things if not rapidly re-run - ui->tabWidget->setCurrentWidget(ui->tab_fav); + this->setCurrentWidget(ui->tab_fav); ui->tool_fav_apps->setChecked(true); ui->tool_fav_dirs->setChecked(false); ui->tool_fav_files->setChecked(false); cfav = 0; //favorite apps updateFavItems(); updateHome(); + if(lastUpdate < LSession::applicationMenu()->lastHashUpdate || lastUpdate.isNull()){ updateAppCategories(); updateApps(); } @@ -222,3 +232,12 @@ void UserWidget::updateHome(){ } static_cast<QBoxLayout*>(ui->scroll_home->widget()->layout())->addStretch(); } + +void UserWidget::mouseMoveEvent( QMouseEvent *event){ + QTabBar *wid = tabBar(); + qDebug() << "Mouse Move Event:"; + if(wid && wid->tabAt(event->pos()) != -1){ + qDebug() << " - Mouse over tab"; + this->setCurrentIndex( wid->tabAt(event->pos()) ); + } +}
\ No newline at end of file |