Skip to content

Commit

Permalink
use own icon instead start-here-kde; make start button without arrow
Browse files Browse the repository at this point in the history
  • Loading branch information
kollix committed Dec 9, 2017
1 parent 9e0ee60 commit e185f09
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
Binary file added 48-apps-liquidshell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion AppMenu.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void AppMenu::fill()
else if ( dirPath == QStandardPaths::writableLocation(QStandardPaths::DesktopLocation) )
button->setIcon(QIcon::fromTheme("user-desktop"));
else // fallback
button->setIcon(QIcon::fromTheme("start-here"));
button->setIcon(QIcon::fromTheme("folder"));

QLayoutItem *child;
while ( (child = popup->layout()->takeAt(0)) )
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
include(KDEInstallDirs)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
include(ECMInstallIcons)

find_package(Qt5 5.6 CONFIG REQUIRED COMPONENTS
Core
Expand Down Expand Up @@ -114,3 +115,8 @@ target_link_libraries(${TARGET}

install(TARGETS ${TARGET} ${INSTALL_TARGETS_DEFAULT_ARGS})
install(PROGRAMS org.kde.${TARGET}.desktop DESTINATION ${XDG_APPS_INSTALL_DIR})

ecm_install_icons(ICONS
48-apps-liquidshell.png
DESTINATION ${ICON_INSTALL_DIR}
THEME hicolor)
30 changes: 21 additions & 9 deletions StartMenu.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,18 @@
//--------------------------------------------------------------------------------

StartMenu::StartMenu(DesktopPanel *parent)
: QPushButton(parent)
: QToolButton(parent)
{
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
setIconSize((parent->getRows() == 1) ? QSize(22, 22) : QSize(48, 48));

connect(parent, &DesktopPanel::rowsChanged,
[this](int rows) { setIconSize((rows == 1) ? QSize(22, 22) : QSize(48, 48)); });

setThemeIcon("start-here-kde");
setThemeIcon("liquidshell");

setMenu(new PopupMenu(this));
popup = new PopupMenu(this);
connect(this, &QToolButton::pressed, this, &StartMenu::showMenu);

fill();

Expand All @@ -62,14 +63,14 @@ void StartMenu::setThemeIcon(const QString &icon)

void StartMenu::fill()
{
menu()->clear();
popup->clear();

fillFromGroup(menu(), KServiceGroup::root());
fillFromGroup(popup, KServiceGroup::root());

menu()->addSeparator();
popup->addSeparator();

// add important actions
QAction *action = menu()->addAction(QIcon::fromTheme("system-switch-user"), i18n("Switch User"));
QAction *action = popup->addAction(QIcon::fromTheme("system-switch-user"), i18n("Switch User"));
connect(action, &QAction::triggered,
[]()
{
Expand All @@ -81,11 +82,11 @@ void StartMenu::fill()
KService::Ptr sysSettings = KService::serviceByDesktopName("systemsettings");
if ( sysSettings )
{
action = menu()->addAction(QIcon::fromTheme(sysSettings->icon()), sysSettings->name());
action = popup->addAction(QIcon::fromTheme(sysSettings->icon()), sysSettings->name());
connect(action, &QAction::triggered, [this, sysSettings]() { KRun::runApplication(*sysSettings, QList<QUrl>(), this); });
}

action = menu()->addAction(QIcon::fromTheme("system-run"), i18n("Run Command..."));
action = popup->addAction(QIcon::fromTheme("system-run"), i18n("Run Command..."));
connect(action, &QAction::triggered,
[]()
{
Expand Down Expand Up @@ -154,3 +155,14 @@ void StartMenu::contextMenuEvent(QContextMenuEvent *event)
}

//--------------------------------------------------------------------------------

void StartMenu::showMenu()
{
popup->adjustSize();
QPoint p = mapToGlobal(QPoint(0, 0));
popup->move(p.x(), p.y() - popup->height());
popup->exec();
setDown(false);
}

//--------------------------------------------------------------------------------
6 changes: 4 additions & 2 deletions StartMenu.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
#ifndef _StartMenu_H_
#define _StartMenu_H_

#include <QPushButton>
#include <QToolButton>
#include <QMenu>

#include <KServiceGroup>

#include <DesktopPanel.hxx>

class StartMenu : public QPushButton
class StartMenu : public QToolButton
{
Q_OBJECT

Expand All @@ -44,12 +44,14 @@ class StartMenu : public QPushButton

private Q_SLOTS:
void fill();
void showMenu();

private:
void fillFromGroup(QMenu *menu, KServiceGroup::Ptr group);

private:
QString themeIcon;
QMenu *popup;
};

#endif

0 comments on commit e185f09

Please sign in to comment.