diff --git a/COPYING b/LICENSE similarity index 96% rename from COPYING rename to LICENSE index a8dd823..20fb9c7 100644 --- a/COPYING +++ b/LICENSE @@ -1,9 +1,8 @@ - GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -23,8 +22,7 @@ specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations -below. +strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that @@ -89,9 +87,9 @@ libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it -becomes a de-facto standard. To achieve this, non-free programs must -be allowed to use the library. A more frequent case is that a free +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. @@ -138,8 +136,8 @@ included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control -compilation and installation of the library. +interface definition files, plus the scripts used to control compilation +and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of @@ -305,10 +303,10 @@ of these things: the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. - c) Accompany the work with a written offer, valid for at least - three years, to give the same user the materials specified in - Subsection 6a, above, for a charge no more than the cost of - performing this distribution. + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above @@ -386,10 +384,9 @@ all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply, and the section as a whole is intended to apply in other -circumstances. +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any @@ -407,11 +404,11 @@ be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License -may add an explicit geographical distribution limitation excluding those -countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. diff --git a/debian/changelog b/debian/changelog index a953efe..9272912 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,12 @@ -lxqt-panel (0.9.0+20151024-1) experimental; urgency=medium +lxqt-panel (0.9.0+20151101-1) unstable; urgency=medium [ Alf Gaida ] - * Cherry-picked upstream version 0.9.0+20151024. + * Cherry-picked upstream version 0.9.0+20151101. + * Install manpage for lxqt-panel + * Deleted debian/lintian-overrides * Cleaned up debian/.gitignore * Switched to experimental because of LXQt namespace change - * Added minimum version for liblxqt0-dev (>= 0.9.0+20150911) + * Added minimum version for liblxqt and libqtxdg * Added upstream signing key and use it in watch file * drop transitional packages * drop breaks/replaces diff --git a/debian/control b/debian/control index 3cd7f2e..355eced 100644 --- a/debian/control +++ b/debian/control @@ -11,7 +11,7 @@ Build-Depends: cmake (>= 3.0.2), libdbusmenu-qt5-dev, libglib2.0-dev, libicu-dev, - liblxqt0-dev (>= 0.9.0-20150911), + liblxqt0-dev (>= 0.9.0-20151026), liblxqt-globalkeys0-dev, liblxqt-globalkeys-ui0-dev, libkf5windowsystem-dev, @@ -19,7 +19,7 @@ Build-Depends: cmake (>= 3.0.2), libmenu-cache-dev, libpulse-dev, libqt5x11extras5-dev, - libqt5xdg-dev, + libqt5xdg-dev (>= 1.3.0), libsensors4-dev, libstatgrab-dev, libsysstat-qt5-0-dev (>= 0.3.0), diff --git a/debian/lintian-overrides b/debian/lintian-overrides deleted file mode 100644 index 5e20d61..0000000 --- a/debian/lintian-overrides +++ /dev/null @@ -1,3 +0,0 @@ -# there will now manpage in a foreseable future -lxqt-panel: binary-without-manpage usr/bin/lxqt-panel - diff --git a/debian/manpages b/debian/manpages new file mode 100644 index 0000000..bac6177 --- /dev/null +++ b/debian/manpages @@ -0,0 +1,2 @@ +panel/man/lxqt-panel.1 + diff --git a/panel/config/addplugindialog.cpp b/panel/config/addplugindialog.cpp index 0c75a64..b282338 100644 --- a/panel/config/addplugindialog.cpp +++ b/panel/config/addplugindialog.cpp @@ -53,7 +53,7 @@ AddPluginDialog::AddPluginDialog(QWidget *parent): desktopFilesDirs << QString("%1/%2").arg(XdgDirs::dataHome(), "/lxqt/lxqt-panel"); desktopFilesDirs << PLUGIN_DESKTOPS_DIR; - mPlugins = LXQt::PluginInfo::search(desktopFilesDirs, QStringLiteral("LXQtPanel/Plugin"), QStringLiteral("*")); + mPlugins = LXQt::PluginInfo::search(desktopFilesDirs, QLatin1String("LXQtPanel/Plugin"), QLatin1String("*")); std::sort(mPlugins.begin(), mPlugins.end(), [](const LXQt::PluginInfo &p1, const LXQt::PluginInfo &p2) { return p1.name() < p2.name() || (p1.name() == p2.name() && p1.comment() < p2.comment()); }); @@ -97,7 +97,7 @@ void AddPluginDialog::filter() { const LXQt::PluginInfo &plugin = mPlugins.at(i); - QString s = QStringLiteral("%1 %2 %3 %4 %5").arg(plugin.name(), + QString s = QString("%1 %2 %3 %4 %5").arg(plugin.name(), plugin.comment(), plugin.value("Name").toString(), plugin.value("Comment").toString(), @@ -111,10 +111,10 @@ void AddPluginDialog::filter() { item->setFlags(item->flags() & ~Qt::ItemIsEnabled); item->setBackground(palette().brush(QPalette::Disabled, QPalette::Text)); - item->setText(QStringLiteral("%1 (%2)
%3
%4") + item->setText(QString("%1 (%2)
%3
%4") .arg(plugin.name(), plugin.id(), plugin.comment(), tr("(only one instance can run at a time)"))); } else - item->setText(QStringLiteral("%1 (%2)
%3").arg(plugin.name(), plugin.id(), plugin.comment())); + item->setText(QString("%1 (%2)
%3").arg(plugin.name(), plugin.id(), plugin.comment())); item->setIcon(plugin.icon(fallIco)); item->setData(INDEX_ROLE, i); } diff --git a/panel/config/configpaneldialog.cpp b/panel/config/configpaneldialog.cpp index 36439db..089ce72 100644 --- a/panel/config/configpaneldialog.cpp +++ b/panel/config/configpaneldialog.cpp @@ -35,11 +35,11 @@ ConfigPanelDialog::ConfigPanelDialog(LXQtPanel *panel, QWidget *parent): setAttribute(Qt::WA_DeleteOnClose); mPanelPage = new ConfigPanelWidget(panel, this); - addPage(mPanelPage, tr("Panel"), QStringLiteral("configure")); + addPage(mPanelPage, tr("Panel"), QLatin1String("configure")); connect(this, &ConfigPanelDialog::reset, mPanelPage, &ConfigPanelWidget::reset); mPluginsPage = new ConfigPluginsWidget(panel, this); - addPage(mPluginsPage, tr("Widgets"), QStringLiteral("preferences-plugin")); + addPage(mPluginsPage, tr("Widgets"), QLatin1String("preferences-plugin")); connect(this, &ConfigPanelDialog::reset, mPluginsPage, &ConfigPluginsWidget::reset); connect(this, &ConfigPanelDialog::accepted, [panel] { diff --git a/panel/lxqtpanel.cpp b/panel/lxqtpanel.cpp index d373689..5159c15 100644 --- a/panel/lxqtpanel.cpp +++ b/panel/lxqtpanel.cpp @@ -472,6 +472,7 @@ void LXQtPanel::updateWmStrut() if(wid == 0 || !isVisible()) return; + const QRect wholeScreen = QApplication::desktop()->geometry(); const QRect rect = geometry(); // NOTE: http://standards.freedesktop.org/wm-spec/wm-spec-latest.html // Quote from the EWMH spec: " Note that the strut is relative to the screen edge, and not the edge of the xinerama monitor." @@ -484,7 +485,7 @@ void LXQtPanel::updateWmStrut() KWindowSystem::setExtendedStrut(wid, /* Left */ 0, 0, 0, /* Right */ 0, 0, 0, - /* Top */ getReserveDimension(), rect.left(), rect.right(), + /* Top */ rect.top() + getReserveDimension(), rect.left(), rect.right(), /* Bottom */ 0, 0, 0 ); break; @@ -494,13 +495,13 @@ void LXQtPanel::updateWmStrut() /* Left */ 0, 0, 0, /* Right */ 0, 0, 0, /* Top */ 0, 0, 0, - /* Bottom */ getReserveDimension(), rect.left(), rect.right() + /* Bottom */ wholeScreen.bottom() - rect.bottom() + getReserveDimension(), rect.left(), rect.right() ); break; case LXQtPanel::PositionLeft: KWindowSystem::setExtendedStrut(wid, - /* Left */ getReserveDimension(), rect.top(), rect.bottom(), + /* Left */ rect.left() + getReserveDimension(), rect.top(), rect.bottom(), /* Right */ 0, 0, 0, /* Top */ 0, 0, 0, /* Bottom */ 0, 0, 0 @@ -511,7 +512,7 @@ void LXQtPanel::updateWmStrut() case LXQtPanel::PositionRight: KWindowSystem::setExtendedStrut(wid, /* Left */ 0, 0, 0, - /* Right */ getReserveDimension(), rect.top(), rect.bottom(), + /* Right */ wholeScreen.right() - rect.right() + getReserveDimension(), rect.top(), rect.bottom(), /* Top */ 0, 0, 0, /* Bottom */ 0, 0, 0 ); @@ -932,7 +933,7 @@ void LXQtPanel::showPopupMenu(Plugin *plugin) menu->addTitle(QIcon(), tr("Panel")); - menu->addAction(XdgIcon::fromTheme(QStringLiteral("configure")), + menu->addAction(XdgIcon::fromTheme(QLatin1String("configure")), tr("Configure Panel"), this, SLOT(showConfigDialog()) ); @@ -950,7 +951,7 @@ void LXQtPanel::showPopupMenu(Plugin *plugin) if (a->count() > 1) { - menu->addAction(XdgIcon::fromTheme(QStringLiteral("list-remove")), + menu->addAction(XdgIcon::fromTheme(QLatin1String("list-remove")), tr("Remove Panel"), this, SLOT(userRequestForDeletion()) ); diff --git a/panel/lxqtpanelapplication.cpp b/panel/lxqtpanelapplication.cpp index 8afc80e..9cfe707 100644 --- a/panel/lxqtpanelapplication.cpp +++ b/panel/lxqtpanelapplication.cpp @@ -39,16 +39,16 @@ LXQtPanelApplication::LXQtPanelApplication(int& argc, char** argv) : LXQt::Application(argc, argv, true) { - QCoreApplication::setApplicationName(QStringLiteral("lxqt-panel")); + QCoreApplication::setApplicationName(QLatin1String("lxqt-panel")); QCoreApplication::setApplicationVersion(LXQT_VERSION); QCommandLineParser parser; - parser.setApplicationDescription(QStringLiteral("LXQt panel")); + parser.setApplicationDescription(QLatin1String("LXQt panel")); parser.addHelpOption(); parser.addVersionOption(); QCommandLineOption configFileOption(QStringList() - << QStringLiteral("c") << QStringLiteral("config") << QStringLiteral("configfile"), + << QLatin1String("c") << QLatin1String("config") << QLatin1String("configfile"), QCoreApplication::translate("main", "Use alternate configuration file."), QCoreApplication::translate("main", "Configuration file")); parser.addOption(configFileOption); @@ -58,7 +58,7 @@ LXQtPanelApplication::LXQtPanelApplication(int& argc, char** argv) const QString configFile = parser.value(configFileOption); if (configFile.isEmpty()) - mSettings = new LXQt::Settings(QStringLiteral("panel"), this); + mSettings = new LXQt::Settings(QLatin1String("panel"), this); else mSettings = new LXQt::Settings(configFile, QSettings::IniFormat, this); diff --git a/panel/man/lxqt-panel.1 b/panel/man/lxqt-panel.1 index c3eb14a..f7fbe4a 100644 --- a/panel/man/lxqt-panel.1 +++ b/panel/man/lxqt-panel.1 @@ -38,7 +38,7 @@ Several plugins are loaded by default, the desktop menu and windows workspaces c By right clickin over there show config setting options for each plugins and also panel itsefl. .SH AUTOSTART The module only are showed on \fBLXQt\fR desktop environment, but you can create an autostart action -for you prefered desktop environment. +for you preferred desktop environment. .SH "REPORTING BUGS" Report bugs to https://github.com/LXDE/LXQt/issues .SH "SEE ALSO" diff --git a/panel/panelpluginsmodel.cpp b/panel/panelpluginsmodel.cpp index 1aa89b1..51eb14c 100644 --- a/panel/panelpluginsmodel.cpp +++ b/panel/panelpluginsmodel.cpp @@ -69,9 +69,9 @@ QVariant PanelPluginsModel::data(const QModelIndex & index, int role/* = Qt::Dis { case Qt::DisplayRole: if (plugin.second.isNull()) - ret = QStringLiteral("Unknown (%1)").arg(plugin.first); + ret = QString("Unknown (%1)").arg(plugin.first); else - ret = QStringLiteral("%1 (%2)").arg(plugin.second->name(), plugin.first); + ret = QString("%1 (%2)").arg(plugin.second->name(), plugin.first); break; case Qt::DecorationRole: if (plugin.second.isNull()) @@ -246,7 +246,7 @@ QString PanelPluginsModel::findNewPluginSettingsGroup(const QString &pluginType) groups.sort(); // Generate new section name - QString pluginName = QStringLiteral("%1").arg(pluginType); + QString pluginName = QString("%1").arg(pluginType); if (!groups.contains(pluginName)) return pluginName; @@ -254,7 +254,7 @@ QString PanelPluginsModel::findNewPluginSettingsGroup(const QString &pluginType) { for (int i = 2; true; ++i) { - pluginName = QStringLiteral("%1%2").arg(pluginType).arg(i); + pluginName = QString("%1%2").arg(pluginType).arg(i); if (!groups.contains(pluginName)) return pluginName; } diff --git a/panel/plugin.cpp b/panel/plugin.cpp index 86be4dc..a4acc78 100644 --- a/panel/plugin.cpp +++ b/panel/plugin.cpp @@ -199,34 +199,34 @@ namespace // to be not stripped (as unused/unreferenced) in static linking time static plugin_tuple_t const static_plugins[] = { #if defined(WITH_CLOCK_PLUGIN) - std::make_tuple(QStringLiteral("clock"), plugin_ptr_t{new LXQtClockPluginLibrary}, loadPluginTranslation_clock_helper),// clock + std::make_tuple(QLatin1String("clock"), plugin_ptr_t{new LXQtClockPluginLibrary}, loadPluginTranslation_clock_helper),// clock #endif #if defined(WITH_DESKTOPSWITCH_PLUGIN) - std::make_tuple(QStringLiteral("desktopswitch"), plugin_ptr_t{new DesktopSwitchPluginLibrary}, loadPluginTranslation_desktopswitch_helper),// desktopswitch + std::make_tuple(QLatin1String("desktopswitch"), plugin_ptr_t{new DesktopSwitchPluginLibrary}, loadPluginTranslation_desktopswitch_helper),// desktopswitch #endif #if defined(WITH_MAINMENU_PLUGIN) - std::make_tuple(QStringLiteral("mainmenu"), plugin_ptr_t{new LXQtMainMenuPluginLibrary}, loadPluginTranslation_mainmenu_helper),// mainmenu + std::make_tuple(QLatin1String("mainmenu"), plugin_ptr_t{new LXQtMainMenuPluginLibrary}, loadPluginTranslation_mainmenu_helper),// mainmenu #endif #if defined(WITH_QUICKLAUNCH_PLUGIN) - std::make_tuple(QStringLiteral("quicklaunch"), plugin_ptr_t{new LXQtQuickLaunchPluginLibrary}, loadPluginTranslation_quicklaunch_helper),// quicklaunch + std::make_tuple(QLatin1String("quicklaunch"), plugin_ptr_t{new LXQtQuickLaunchPluginLibrary}, loadPluginTranslation_quicklaunch_helper),// quicklaunch #endif #if defined(WITH_SHOWDESKTOP_PLUGIN) - std::make_tuple(QStringLiteral("showdesktop"), plugin_ptr_t{new ShowDesktopLibrary}, loadPluginTranslation_showdesktop_helper),// showdesktop + std::make_tuple(QLatin1String("showdesktop"), plugin_ptr_t{new ShowDesktopLibrary}, loadPluginTranslation_showdesktop_helper),// showdesktop #endif #if defined(WITH_SPACER_PLUGIN) - std::make_tuple(QStringLiteral("spacer"), plugin_ptr_t{new SpacerPluginLibrary}, loadPluginTranslation_spacer_helper),// spacer + std::make_tuple(QLatin1String("spacer"), plugin_ptr_t{new SpacerPluginLibrary}, loadPluginTranslation_spacer_helper),// spacer #endif #if defined(WITH_STATUSNOTIFIER_PLUGIN) - std::make_tuple(QStringLiteral("statusnotifier"), plugin_ptr_t{new StatusNotifierLibrary}, loadPluginTranslation_statusnotifier_helper),// statusnotifier + std::make_tuple(QLatin1String("statusnotifier"), plugin_ptr_t{new StatusNotifierLibrary}, loadPluginTranslation_statusnotifier_helper),// statusnotifier #endif #if defined(WITH_TASKBAR_PLUGIN) - std::make_tuple(QStringLiteral("taskbar"), plugin_ptr_t{new LXQtTaskBarPluginLibrary}, loadPluginTranslation_taskbar_helper),// taskbar + std::make_tuple(QLatin1String("taskbar"), plugin_ptr_t{new LXQtTaskBarPluginLibrary}, loadPluginTranslation_taskbar_helper),// taskbar #endif #if defined(WITH_TRAY_PLUGIN) - std::make_tuple(QStringLiteral("tray"), plugin_ptr_t{new LXQtTrayPluginLibrary}, loadPluginTranslation_tray_helper),// tray + std::make_tuple(QLatin1String("tray"), plugin_ptr_t{new LXQtTrayPluginLibrary}, loadPluginTranslation_tray_helper),// tray #endif #if defined(WITH_WORLDCLOCK_PLUGIN) - std::make_tuple(QStringLiteral("worldclock"), plugin_ptr_t{new LXQtWorldClockLibrary}, loadPluginTranslation_worldclock_helper),// worldclock + std::make_tuple(QLatin1String("worldclock"), plugin_ptr_t{new LXQtWorldClockLibrary}, loadPluginTranslation_worldclock_helper),// worldclock #endif }; static constexpr plugin_tuple_t const * const plugins_begin = static_plugins; @@ -408,7 +408,7 @@ QMenu *Plugin::popupMenu() const if (mPlugin->flags().testFlag(ILXQtPanelPlugin::HaveConfigDialog)) { QAction* configAction = new QAction( - XdgIcon::fromTheme(QStringLiteral("preferences-other")), + XdgIcon::fromTheme(QLatin1String("preferences-other")), tr("Configure \"%1\"").arg(name), menu); menu->addAction(configAction); connect(configAction, SIGNAL(triggered()), this, SLOT(showConfigureDialog())); @@ -421,7 +421,7 @@ QMenu *Plugin::popupMenu() const menu->addSeparator(); QAction* removeAction = new QAction( - XdgIcon::fromTheme(QStringLiteral("list-remove")), + XdgIcon::fromTheme(QLatin1String("list-remove")), tr("Remove \"%1\"").arg(name), menu); menu->addAction(removeAction); connect(removeAction, SIGNAL(triggered()), this, SLOT(requestRemove())); diff --git a/plugin-desktopswitch/desktopswitch.cpp b/plugin-desktopswitch/desktopswitch.cpp index 992dde5..9531d65 100644 --- a/plugin-desktopswitch/desktopswitch.cpp +++ b/plugin-desktopswitch/desktopswitch.cpp @@ -41,7 +41,7 @@ #include "desktopswitchbutton.h" #include "desktopswitchconfiguration.h" -#define DEFAULT_SHORTCUT_TEMPLATE QStringLiteral("Control+F%1") +static const QString DEFAULT_SHORTCUT_TEMPLATE("Control+F%1"); DesktopSwitch::DesktopSwitch(const ILXQtPanelPluginStartupInfo &startupInfo) : QObject(), @@ -84,7 +84,7 @@ void DesktopSwitch::registerShortcuts() path = QString("/panel/%1/desktop_%2").arg(settings()->group()).arg(i + 1); description = tr("Switch to desktop %1").arg(i + 1); - gshortcut = GlobalKeyShortcut::Client::instance()->addAction(QStringLiteral(), path, description, this); + gshortcut = GlobalKeyShortcut::Client::instance()->addAction(QString(), path, description, this); if (nullptr != gshortcut) { m_keys << gshortcut; diff --git a/plugin-kbindicator/src/kbdstateconfig.cpp b/plugin-kbindicator/src/kbdstateconfig.cpp index 343ac8a..de05ba6 100644 --- a/plugin-kbindicator/src/kbdstateconfig.cpp +++ b/plugin-kbindicator/src/kbdstateconfig.cpp @@ -106,5 +106,5 @@ void KbdStateConfig::save() void KbdStateConfig::configureLayouts() { - QProcess::startDetached(QStringLiteral("lxqt-config-input")); + QProcess::startDetached(QLatin1String("lxqt-config-input")); } diff --git a/plugin-mainmenu/lxqtmainmenu.cpp b/plugin-mainmenu/lxqtmainmenu.cpp index 045bd39..9673a4f 100644 --- a/plugin-mainmenu/lxqtmainmenu.cpp +++ b/plugin-mainmenu/lxqtmainmenu.cpp @@ -63,8 +63,7 @@ LXQtMainMenu::LXQtMainMenu(const ILXQtPanelPluginStartupInfo &startupInfo): QObject(), ILXQtPanelPlugin(startupInfo), mMenu(0), - mShortcut(0), - mLockCascadeChanges(false) + mShortcut(0) { #ifdef HAVE_MENU_CACHE mMenuCache = NULL; @@ -84,8 +83,15 @@ LXQtMainMenu::LXQtMainMenu(const ILXQtPanelPluginStartupInfo &startupInfo): settingsChanged(); - connect(mShortcut, SIGNAL(activated()), &mDelayedPopup, SLOT(start())); - connect(mShortcut, SIGNAL(shortcutChanged(QString,QString)), this, SLOT(shortcutChanged(QString,QString))); + mShortcut = GlobalKeyShortcut::Client::instance()->addAction(QString{}, QString("/panel/%1/show_hide").arg(settings()->group()), tr("Show/hide main menu"), this); + if (mShortcut) + { + connect(mShortcut, &GlobalKeyShortcut::Action::registrationFinished, [this] { + if (mShortcut->shortcut().isEmpty()) + mShortcut->changeShortcut(DEFAULT_SHORTCUT); + }); + connect(mShortcut, &GlobalKeyShortcut::Action::activated, [this] { if (!mHideTimer.isActive()) mDelayedPopup.start(); }); + } } @@ -110,31 +116,12 @@ LXQtMainMenu::~LXQtMainMenu() ************************************************/ void LXQtMainMenu::showHideMenu() { - - if (mMenu && (mMenu->isVisible() || mHideTimer.isActive())) + if (mMenu && mMenu->isVisible()) mMenu->hide(); else showMenu(); } -/************************************************ - - ************************************************/ -void LXQtMainMenu::shortcutChanged(const QString &/*oldShortcut*/, const QString &newShortcut) -{ - if (!newShortcut.isEmpty()) - { - mLockCascadeChanges = true; - - settings()->setValue("dialog/shortcut", newShortcut); - settings()->sync(); - mShortcutSeq = QKeySequence(newShortcut); - - mLockCascadeChanges = false; - } -} - - /************************************************ ************************************************/ @@ -161,9 +148,6 @@ void LXQtMainMenu::menuCacheReloadNotify(MenuCache* cache, gpointer user_data) ************************************************/ void LXQtMainMenu::settingsChanged() { - if (mLockCascadeChanges) - return; - if (settings()->value("showText", false).toBool()) { mButton.setText(settings()->value("text", "Start").toString()); @@ -213,18 +197,6 @@ void LXQtMainMenu::settingsChanged() #endif } - QString shortcut = settings()->value("shortcut", DEFAULT_SHORTCUT).toString(); - if (shortcut.isEmpty()) - shortcut = DEFAULT_SHORTCUT; - - if (!mShortcut) - mShortcut = GlobalKeyShortcut::Client::instance()->addAction(shortcut, QString("/panel/%1/show_hide").arg(settings()->group()), tr("Show/hide main menu"), this); - else if (mShortcut->shortcut() != shortcut) - { - mShortcut->changeShortcut(shortcut); - } - mShortcutSeq = QKeySequence(shortcut); - setMenuFontSize(); realign(); @@ -301,7 +273,7 @@ void LXQtMainMenu::setMenuFontSize() ************************************************/ QDialog *LXQtMainMenu::configureDialog() { - return new LXQtMainMenuConfiguration(*settings(), DEFAULT_SHORTCUT); + return new LXQtMainMenuConfiguration(*settings(), mShortcut, DEFAULT_SHORTCUT); } /************************************************ @@ -333,8 +305,9 @@ bool LXQtMainMenu::eventFilter(QObject *obj, QEvent *event) { // if our shortcut key is pressed while the menu is open, close the menu QKeyEvent* keyEvent = static_cast(event); - if(mShortcutSeq == QKeySequence(keyEvent->modifiers() + keyEvent->key())) + if (keyEvent->modifiers() & ~Qt::ShiftModifier) { + mHideTimer.start(); mMenu->hide(); // close the app menu return true; } diff --git a/plugin-mainmenu/lxqtmainmenu.h b/plugin-mainmenu/lxqtmainmenu.h index 5253407..117cd9f 100644 --- a/plugin-mainmenu/lxqtmainmenu.h +++ b/plugin-mainmenu/lxqtmainmenu.h @@ -95,10 +95,8 @@ private: XdgMenu mXdgMenu; #endif - bool mLockCascadeChanges; QTimer mDelayedPopup; QTimer mHideTimer; - QKeySequence mShortcutSeq; QString mMenuFile; protected slots: @@ -109,7 +107,6 @@ protected slots: private slots: void showMenu(); void showHideMenu(); - void shortcutChanged(const QString &oldShortcut, const QString &newShortcut); }; class LXQtMainMenuPluginLibrary: public QObject, public ILXQtPanelPluginLibrary diff --git a/plugin-mainmenu/lxqtmainmenuconfiguration.cpp b/plugin-mainmenu/lxqtmainmenuconfiguration.cpp index 332c523..c7f09ee 100644 --- a/plugin-mainmenu/lxqtmainmenuconfiguration.cpp +++ b/plugin-mainmenu/lxqtmainmenuconfiguration.cpp @@ -30,15 +30,17 @@ #include "ui_lxqtmainmenuconfiguration.h" #include #include +#include #include -LXQtMainMenuConfiguration::LXQtMainMenuConfiguration(QSettings &settings, const QString &defaultShortcut, QWidget *parent) : +LXQtMainMenuConfiguration::LXQtMainMenuConfiguration(QSettings &settings, GlobalKeyShortcut::Action * shortcut, const QString &defaultShortcut, QWidget *parent) : QDialog(parent), ui(new Ui::LXQtMainMenuConfiguration), mSettings(settings), mOldSettings(settings), - mDefaultShortcut(defaultShortcut) + mDefaultShortcut(defaultShortcut), + mShortcut(shortcut) { setAttribute(Qt::WA_DeleteOnClose); setObjectName("MainMenuConfigurationWindow"); @@ -55,7 +57,7 @@ LXQtMainMenuConfiguration::LXQtMainMenuConfiguration(QSettings &settings, const connect(ui->chooseMenuFilePB, SIGNAL(clicked()), this, SLOT(chooseMenuFile())); connect(ui->menuFilePathLE, &QLineEdit::textChanged, [this] (QString const & file) { - mSettings.setValue(QStringLiteral("menu_file"), file); + mSettings.setValue(QLatin1String("menu_file"), file); }); connect(ui->shortcutEd, SIGNAL(shortcutGrabbed(QString)), this, SLOT(shortcutChanged(QString))); @@ -63,6 +65,8 @@ LXQtMainMenuConfiguration::LXQtMainMenuConfiguration(QSettings &settings, const connect(ui->customFontCB, SIGNAL(toggled(bool)), this, SLOT(customFontChanged(bool))); connect(ui->customFontSizeSB, SIGNAL(valueChanged(int)), this, SLOT(customFontSizeChanged(int))); + + connect(mShortcut, &GlobalKeyShortcut::Action::shortcutChanged, this, &LXQtMainMenuConfiguration::globalShortcutChanged); } LXQtMainMenuConfiguration::~LXQtMainMenuConfiguration() @@ -81,7 +85,7 @@ void LXQtMainMenuConfiguration::loadSettings() menuFile = XdgMenu::getMenuFileName(); } ui->menuFilePathLE->setText(menuFile); - ui->shortcutEd->setText(mSettings.value("shortcut", "Alt+F1").toString()); + ui->shortcutEd->setText(nullptr != mShortcut ? mShortcut->shortcut() : mDefaultShortcut); ui->customFontCB->setChecked(mSettings.value("customFont", false).toBool()); LXQt::Settings lxqtSettings("lxqt"); //load system font size as init value @@ -106,7 +110,7 @@ void LXQtMainMenuConfiguration::chooseMenuFile() { QFileDialog *d = new QFileDialog(this, tr("Choose menu file"), - QStringLiteral("/etc/xdg/menus"), + QLatin1String("/etc/xdg/menus"), tr("Menu files (*.menu)")); d->setWindowModality(Qt::WindowModal); d->setAttribute(Qt::WA_DeleteOnClose); @@ -116,10 +120,15 @@ void LXQtMainMenuConfiguration::chooseMenuFile() d->show(); } +void LXQtMainMenuConfiguration::globalShortcutChanged(const QString &/*oldShortcut*/, const QString &newShortcut) +{ + ui->shortcutEd->setText(newShortcut); +} + void LXQtMainMenuConfiguration::shortcutChanged(const QString &value) { - ui->shortcutEd->setText(value); - mSettings.setValue("shortcut", value); + if (mShortcut) + mShortcut->changeShortcut(value); } void LXQtMainMenuConfiguration::shortcutReset() diff --git a/plugin-mainmenu/lxqtmainmenuconfiguration.h b/plugin-mainmenu/lxqtmainmenuconfiguration.h index 874b02a..1d1cf4e 100644 --- a/plugin-mainmenu/lxqtmainmenuconfiguration.h +++ b/plugin-mainmenu/lxqtmainmenuconfiguration.h @@ -40,12 +40,16 @@ namespace Ui { class LXQtMainMenuConfiguration; } +namespace GlobalKeyShortcut { + class Action; +} + class LXQtMainMenuConfiguration : public QDialog { Q_OBJECT public: - explicit LXQtMainMenuConfiguration(QSettings &settings, const QString &defaultShortcut, QWidget *parent = 0); + explicit LXQtMainMenuConfiguration(QSettings &settings, GlobalKeyShortcut::Action * shortcut, const QString &defaultShortcut, QWidget *parent = 0); ~LXQtMainMenuConfiguration(); private: @@ -53,8 +57,11 @@ private: QSettings &mSettings; LXQt::SettingsCache mOldSettings; QString mDefaultShortcut; + GlobalKeyShortcut::Action * mShortcut; private slots: + void globalShortcutChanged(const QString &oldShortcut, const QString &newShortcut); + void shortcutChanged(const QString &value); /* Saves settings in conf file. */ @@ -63,7 +70,6 @@ private slots: void textButtonChanged(const QString &value); void showTextChanged(bool value); void chooseMenuFile(); - void shortcutChanged(const QString &value); void shortcutReset(); void customFontChanged(bool value); void customFontSizeChanged(int value); diff --git a/plugin-mount/button.cpp b/plugin-mount/button.cpp index 962f438..26473fa 100644 --- a/plugin-mount/button.cpp +++ b/plugin-mount/button.cpp @@ -32,7 +32,9 @@ Button::Button(QWidget * parent) : QToolButton(parent) { - setIcon(XdgIcon::fromTheme(QStringLiteral("drive-removable-media"))); + //Note: don't use the QStringLiteral here as it is causing a SEGFAULT in static finalization time + //(the string is released upon our *.so removal, but the reference is still in held in libqtxdg...) + setIcon(XdgIcon::fromTheme(QLatin1String("drive-removable-media"))); setToolTip(tr("Removable media/devices manager")); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); } diff --git a/plugin-mount/configuration.cpp b/plugin-mount/configuration.cpp index b24e3c4..4bf54f8 100644 --- a/plugin-mount/configuration.cpp +++ b/plugin-mount/configuration.cpp @@ -37,9 +37,9 @@ Configuration::Configuration(QSettings &settings, QWidget *parent) : ui(new Ui::Configuration) { ui->setupUi(this); - ui->devAddedCombo->addItem(tr("Popup menu"), QStringLiteral(ACT_SHOW_MENU)); - ui->devAddedCombo->addItem(tr("Show info"), QStringLiteral(ACT_SHOW_INFO)); - ui->devAddedCombo->addItem(tr("Do nothing"), QStringLiteral(ACT_NOTHING)); + ui->devAddedCombo->addItem(tr("Popup menu"), QLatin1String(ACT_SHOW_MENU)); + ui->devAddedCombo->addItem(tr("Show info"), QLatin1String(ACT_SHOW_INFO)); + ui->devAddedCombo->addItem(tr("Do nothing"), QLatin1String(ACT_NOTHING)); loadSettings(); connect(ui->devAddedCombo, static_cast(&QComboBox::currentIndexChanged), @@ -54,12 +54,12 @@ Configuration::~Configuration() void Configuration::loadSettings() { - QVariant value = settings().value(QStringLiteral(CFG_KEY_ACTION), QStringLiteral(ACT_SHOW_INFO)); + QVariant value = settings().value(QLatin1String(CFG_KEY_ACTION), QLatin1String(ACT_SHOW_INFO)); setComboboxIndexByData(ui->devAddedCombo, value, 1); } void Configuration::devAddedChanged(int index) { QString s = ui->devAddedCombo->itemData(index).toString(); - settings().setValue(QStringLiteral(CFG_KEY_ACTION), s); + settings().setValue(QLatin1String(CFG_KEY_ACTION), s); } diff --git a/plugin-mount/lxqtmountplugin.cpp b/plugin-mount/lxqtmountplugin.cpp index e106d7d..ea3b6dc 100644 --- a/plugin-mount/lxqtmountplugin.cpp +++ b/plugin-mount/lxqtmountplugin.cpp @@ -66,7 +66,7 @@ void LXQtMountPlugin::realign() void LXQtMountPlugin::settingsChanged() { - QString s = settings()->value(QStringLiteral(CFG_KEY_ACTION)).toString(); + QString s = settings()->value(QLatin1String(CFG_KEY_ACTION)).toString(); DeviceAction::ActionId actionId = DeviceAction::stringToActionId(s, DeviceAction::ActionMenu); if (mDeviceAction == nullptr || mDeviceAction->Type() != actionId) diff --git a/plugin-mount/lxqtmountplugin.h b/plugin-mount/lxqtmountplugin.h index 4f30104..08a102e 100644 --- a/plugin-mount/lxqtmountplugin.h +++ b/plugin-mount/lxqtmountplugin.h @@ -49,7 +49,7 @@ public: ~LXQtMountPlugin(); virtual QWidget *widget() { return mButton; } - virtual QString themeId() const { return QStringLiteral("LXQtMount"); } + virtual QString themeId() const { return QLatin1String("LXQtMount"); } virtual ILXQtPanelPlugin::Flags flags() const { return PreferRightAlignment | HaveConfigDialog; } Popup *popup() { return mPopup; } diff --git a/plugin-mount/menudiskitem.cpp b/plugin-mount/menudiskitem.cpp index d5381fb..783ebf1 100644 --- a/plugin-mount/menudiskitem.cpp +++ b/plugin-mount/menudiskitem.cpp @@ -89,7 +89,9 @@ void MenuDiskItem::setMountStatus(bool mounted) void MenuDiskItem::updateMountStatus() { - static const QIcon icon = XdgIcon::fromTheme(mDevice.icon(), QStringLiteral("drive-removable-media")); + //Note: don't use the QStringLiteral here as it is causing a SEGFAULT in static finalization time + //(the string is released upon our *.so removal, but the reference is still in held in libqtxdg...) + static const QIcon icon = XdgIcon::fromTheme(mDevice.icon(), QLatin1String("drive-removable-media")); if (mDevice.isValid()) { diff --git a/plugin-spacer/spacerconfiguration.cpp b/plugin-spacer/spacerconfiguration.cpp index 22fe346..92aa7d4 100644 --- a/plugin-spacer/spacerconfiguration.cpp +++ b/plugin-spacer/spacerconfiguration.cpp @@ -31,9 +31,9 @@ //Note: strings can't actually be translated here (in static initialization time) // the QT_TR_NOOP here is just for qt translate tools to get the strings for translation const QStringList SpacerConfiguration::msTypes = { - QStringLiteral(QT_TR_NOOP("lined")) - , QStringLiteral(QT_TR_NOOP("dotted")) - , QStringLiteral(QT_TR_NOOP("invisible")) + QLatin1String(QT_TR_NOOP("lined")) + , QLatin1String(QT_TR_NOOP("dotted")) + , QLatin1String(QT_TR_NOOP("invisible")) }; SpacerConfiguration::SpacerConfiguration(QSettings *settings, QWidget *parent) diff --git a/plugin-statusnotifier/sniasync.cpp b/plugin-statusnotifier/sniasync.cpp index f888d13..a20172a 100644 --- a/plugin-statusnotifier/sniasync.cpp +++ b/plugin-statusnotifier/sniasync.cpp @@ -42,7 +42,7 @@ SniAsync::SniAsync(const QString &service, const QString &path, const QDBusConne QDBusPendingReply SniAsync::asyncPropGet(QString const & property) { - QDBusMessage msg = QDBusMessage::createMethodCall(mSni.service(), mSni.path(), QStringLiteral("org.freedesktop.DBus.Properties"), QStringLiteral("Get")); + QDBusMessage msg = QDBusMessage::createMethodCall(mSni.service(), mSni.path(), QLatin1String("org.freedesktop.DBus.Properties"), QLatin1String("Get")); msg << mSni.interface() << property; return mSni.connection().asyncCall(msg); } diff --git a/plugin-statusnotifier/statusnotifierbutton.cpp b/plugin-statusnotifier/statusnotifierbutton.cpp index ee73324..fb124c6 100644 --- a/plugin-statusnotifier/statusnotifierbutton.cpp +++ b/plugin-statusnotifier/statusnotifierbutton.cpp @@ -50,20 +50,20 @@ StatusNotifierButton::StatusNotifierButton(QString service, QString objectPath, connect(interface, &SniAsync::NewToolTip, this, &StatusNotifierButton::newToolTip); connect(interface, &SniAsync::NewStatus, this, &StatusNotifierButton::newStatus); - interface->propertyGetAsync(QStringLiteral("Menu"), [this] (QDBusObjectPath path) { + interface->propertyGetAsync(QLatin1String("Menu"), [this] (QDBusObjectPath path) { if (!path.path().isEmpty()) { mMenu = (new DBusMenuImporter(interface->service(), path.path(), this))->menu(); dynamic_cast(*mMenu).setParent(this); - mMenu->setObjectName(QStringLiteral("StatusNotifierMenu")); + mMenu->setObjectName(QLatin1String("StatusNotifierMenu")); } }); - interface->propertyGetAsync(QStringLiteral("Status"), [this] (QString status) { + interface->propertyGetAsync(QLatin1String("Status"), [this] (QString status) { newStatus(status); }); - interface->propertyGetAsync(QStringLiteral("IconThemePath"), [this] (QString value) { + interface->propertyGetAsync(QLatin1String("IconThemePath"), [this] (QString value) { mThemePath = value; //do the logic of icons after we've got the theme path refetchIcon(Active); @@ -99,18 +99,18 @@ void StatusNotifierButton::refetchIcon(Status status) QString nameProperty, pixmapProperty; if (status == Active) { - nameProperty = QStringLiteral("OverlayIconName"); - pixmapProperty = QStringLiteral("OverlayIconPixmap"); + nameProperty = QLatin1String("OverlayIconName"); + pixmapProperty = QLatin1String("OverlayIconPixmap"); } else if (status == NeedsAttention) { - nameProperty = QStringLiteral("AttentionIconName"); - pixmapProperty = QStringLiteral("AttentionIconPixmap"); + nameProperty = QLatin1String("AttentionIconName"); + pixmapProperty = QLatin1String("AttentionIconPixmap"); } else // status == Passive { - nameProperty = QStringLiteral("IconName"); - pixmapProperty = QStringLiteral("IconPixmap"); + nameProperty = QLatin1String("IconName"); + pixmapProperty = QLatin1String("IconPixmap"); } interface->propertyGetAsync(nameProperty, [this, status, pixmapProperty] (QString iconName) { @@ -204,12 +204,12 @@ void StatusNotifierButton::refetchIcon(Status status) void StatusNotifierButton::newToolTip() { - interface->propertyGetAsync(QStringLiteral("ToolTip"), [this] (ToolTip tooltip) { + interface->propertyGetAsync(QLatin1String("ToolTip"), [this] (ToolTip tooltip) { QString toolTipTitle = tooltip.title; if (!toolTipTitle.isEmpty()) setToolTip(toolTipTitle); else - interface->propertyGetAsync(QStringLiteral("Title"), [this] (QString title) { + interface->propertyGetAsync(QLatin1String("Title"), [this] (QString title) { // we should get here only in case the ToolTip.title was empty if (!title.isEmpty()) setToolTip(title); @@ -220,9 +220,9 @@ void StatusNotifierButton::newToolTip() void StatusNotifierButton::newStatus(QString status) { Status newStatus; - if (status == QStringLiteral("Passive")) + if (status == QLatin1String("Passive")) newStatus = Passive; - else if (status == QStringLiteral("Active")) + else if (status == QLatin1String("Active")) newStatus = Active; else newStatus = NeedsAttention; diff --git a/plugin-statusnotifier/statusnotifieriteminterface.h b/plugin-statusnotifier/statusnotifieriteminterface.h index fd5854e..4e1435f 100644 --- a/plugin-statusnotifier/statusnotifieriteminterface.h +++ b/plugin-statusnotifier/statusnotifieriteminterface.h @@ -133,28 +133,28 @@ public Q_SLOTS: // METHODS { QList argumentList; argumentList << QVariant::fromValue(x) << QVariant::fromValue(y); - return asyncCallWithArgumentList(QStringLiteral("Activate"), argumentList); + return asyncCallWithArgumentList(QLatin1String("Activate"), argumentList); } inline QDBusPendingReply<> ContextMenu(int x, int y) { QList argumentList; argumentList << QVariant::fromValue(x) << QVariant::fromValue(y); - return asyncCallWithArgumentList(QStringLiteral("ContextMenu"), argumentList); + return asyncCallWithArgumentList(QLatin1String("ContextMenu"), argumentList); } inline QDBusPendingReply<> Scroll(int delta, const QString &orientation) { QList argumentList; argumentList << QVariant::fromValue(delta) << QVariant::fromValue(orientation); - return asyncCallWithArgumentList(QStringLiteral("Scroll"), argumentList); + return asyncCallWithArgumentList(QLatin1String("Scroll"), argumentList); } inline QDBusPendingReply<> SecondaryActivate(int x, int y) { QList argumentList; argumentList << QVariant::fromValue(x) << QVariant::fromValue(y); - return asyncCallWithArgumentList(QStringLiteral("SecondaryActivate"), argumentList); + return asyncCallWithArgumentList(QLatin1String("SecondaryActivate"), argumentList); } Q_SIGNALS: // SIGNALS diff --git a/plugin-sysstat/lxqtsysstat.cpp b/plugin-sysstat/lxqtsysstat.cpp index acfea6c..e4042ff 100644 --- a/plugin-sysstat/lxqtsysstat.cpp +++ b/plugin-sysstat/lxqtsysstat.cpp @@ -620,7 +620,7 @@ void LXQtSysStatContent::paintEvent(QPaintEvent *event) void LXQtSysStatContent::toolTipInfo(QString const & tooltip) { - setToolTip(QStringLiteral("%1(%2)
%3") + setToolTip(QString("%1(%2)
%3") .arg(QCoreApplication::translate("LXQtSysStatConfiguration", mDataType.toStdString().c_str())) .arg(QCoreApplication::translate("LXQtSysStatConfiguration", mDataSource.toStdString().c_str())) .arg(tooltip)); diff --git a/plugin-sysstat/lxqtsysstatconfiguration.cpp b/plugin-sysstat/lxqtsysstatconfiguration.cpp index 8075adc..3419776 100644 --- a/plugin-sysstat/lxqtsysstatconfiguration.cpp +++ b/plugin-sysstat/lxqtsysstatconfiguration.cpp @@ -38,9 +38,9 @@ //Note: strings can't actually be translated here (in static initialization time) // the QT_TR_NOOP here is just for qt translate tools to get the strings for translation const QStringList LXQtSysStatConfiguration::msStatTypes = { - QStringLiteral(QT_TR_NOOP("CPU")) - , QStringLiteral(QT_TR_NOOP("Memory")) - , QStringLiteral(QT_TR_NOOP("Network")) + QLatin1String(QT_TR_NOOP("CPU")) + , QLatin1String(QT_TR_NOOP("Memory")) + , QLatin1String(QT_TR_NOOP("Network")) }; namespace diff --git a/plugin-taskbar/lxqttaskbar.cpp b/plugin-taskbar/lxqttaskbar.cpp index f7c024b..6fd6074 100644 --- a/plugin-taskbar/lxqttaskbar.cpp +++ b/plugin-taskbar/lxqttaskbar.cpp @@ -142,7 +142,7 @@ void LXQtTaskBar::dragEnterEvent(QDragEnterEvent* event) if (event->mimeData()->hasFormat(LXQtTaskGroup::mimeDataFormat())) { event->acceptProposedAction(); - buttonMove(nullptr, LXQtTaskGroup::mimeDataData(event->mimeData()), event->pos()); + buttonMove(nullptr, qobject_cast(event->source()), event->pos()); } else event->ignore(); QWidget::dragEnterEvent(event); @@ -154,23 +154,22 @@ void LXQtTaskBar::dragEnterEvent(QDragEnterEvent* event) void LXQtTaskBar::dragMoveEvent(QDragMoveEvent * event) { //we don't get any dragMoveEvents if dragEnter wasn't accepted - buttonMove(nullptr, LXQtTaskGroup::mimeDataData(event->mimeData()), event->pos()); + buttonMove(nullptr, qobject_cast(event->source()), event->pos()); QWidget::dragMoveEvent(event); } /************************************************ ************************************************/ -void LXQtTaskBar::buttonMove(LXQtTaskGroup * dst, QString const & srcWindow, QPoint const & pos) +void LXQtTaskBar::buttonMove(LXQtTaskGroup * dst, LXQtTaskGroup * src, QPoint const & pos) { - LXQtTaskGroup *src_group = mGroupsHash.value(srcWindow, nullptr); - if (!src_group) + int src_index; + if (!src || -1 == (src_index = mLayout->indexOf(src))) { qDebug() << "Dropped invalid"; return; } - const int src_index = mLayout->indexOf(src_group); const int size = mLayout->count(); Q_ASSERT(0 < size); //dst is nullptr in case the drop occured on empty space in taskbar @@ -245,8 +244,8 @@ void LXQtTaskBar::addWindow(WId window, QString const & groupId) connect(group, SIGNAL(visibilityChanged(bool)), this, SLOT(refreshPlaceholderVisibility())); connect(group, &LXQtTaskGroup::popupShown, this, &LXQtTaskBar::groupPopupShown); connect(group, SIGNAL(windowDisowned(WId)), this, SLOT(refreshTaskList())); - connect(group, &LXQtTaskButton::dragging, this, [this] (QString const & mimeWindow, QPoint const & pos) { - buttonMove(qobject_cast(sender()), mimeWindow, pos); + connect(group, &LXQtTaskButton::dragging, this, [this] (QObject * dragSource, QPoint const & pos) { + buttonMove(qobject_cast(sender()), qobject_cast(dragSource), pos); }); mLayout->addWidget(group); diff --git a/plugin-taskbar/lxqttaskbar.h b/plugin-taskbar/lxqttaskbar.h index 43635c8..661d603 100644 --- a/plugin-taskbar/lxqttaskbar.h +++ b/plugin-taskbar/lxqttaskbar.h @@ -95,7 +95,7 @@ private slots: private: void addWindow(WId window, QString const & groupId); - void buttonMove(LXQtTaskGroup * dst, QString const & srcWindow, QPoint const & pos); + void buttonMove(LXQtTaskGroup * dst, LXQtTaskGroup * src, QPoint const & pos); private: QHash mGroupsHash; diff --git a/plugin-taskbar/lxqttaskbarconfiguration.cpp b/plugin-taskbar/lxqttaskbarconfiguration.cpp index 1e24e66..3ed9e09 100644 --- a/plugin-taskbar/lxqttaskbarconfiguration.cpp +++ b/plugin-taskbar/lxqttaskbarconfiguration.cpp @@ -52,7 +52,7 @@ LXQtTaskbarConfiguration::LXQtTaskbarConfiguration(QSettings &settings, QWidget //Note: in KWindowSystem desktops are numbered from 1..N const int desk_cnt = KWindowSystem::numberOfDesktops(); for (int i = 1; desk_cnt >= i; ++i) - ui->showDesktopNumCB->addItem(QStringLiteral("%1 - %2").arg(i).arg(KWindowSystem::desktopName(i)), i); + ui->showDesktopNumCB->addItem(QString("%1 - %2").arg(i).arg(KWindowSystem::desktopName(i)), i); loadSettings(); diff --git a/plugin-taskbar/lxqttaskbutton.cpp b/plugin-taskbar/lxqttaskbutton.cpp index 36c35e9..b3cb5bc 100644 --- a/plugin-taskbar/lxqttaskbutton.cpp +++ b/plugin-taskbar/lxqttaskbutton.cpp @@ -70,17 +70,6 @@ void LeftAlignedTextStyle::drawItemText(QPainter * painter, const QRect & rect, } -/************************************************ - -************************************************/ -QString LXQtTaskButton::mimeDataData(QMimeData const * mime) -{ - QString data; - QDataStream stream(mime->data(mimeDataFormat())); - stream >> data; - return data; -} - /************************************************ ************************************************/ @@ -173,7 +162,7 @@ void LXQtTaskButton::dragEnterEvent(QDragEnterEvent *event) event->acceptProposedAction(); if (event->mimeData()->hasFormat(mimeDataFormat())) { - emit dragging(mimeDataData(event->mimeData()), event->pos()); + emit dragging(event->source(), event->pos()); setAttribute(Qt::WA_UnderMouse, false); } else { @@ -187,7 +176,7 @@ void LXQtTaskButton::dragMoveEvent(QDragMoveEvent * event) { if (event->mimeData()->hasFormat(mimeDataFormat())) { - emit dragging(mimeDataData(event->mimeData()), event->pos()); + emit dragging(event->source(), event->pos()); setAttribute(Qt::WA_UnderMouse, false); } } @@ -203,7 +192,7 @@ void LXQtTaskButton::dropEvent(QDropEvent *event) mDNDTimer->stop(); if (event->mimeData()->hasFormat(mimeDataFormat())) { - emit dropped(mimeDataData(event->mimeData()), event->pos()); + emit dropped(event->source(), event->pos()); setAttribute(Qt::WA_UnderMouse, false); } QToolButton::dropEvent(event); @@ -266,7 +255,20 @@ void LXQtTaskButton::mouseMoveEvent(QMouseEvent* event) QDrag *drag = new QDrag(this); drag->setMimeData(mimeData()); QIcon ico = icon(); - drag->setPixmap(ico.pixmap(ico.actualSize({32, 32}))); + QPixmap img = ico.pixmap(ico.actualSize({32, 32})); + drag->setPixmap(img); + switch (parentTaskBar()->panel()->position()) + { + case ILXQtPanel::PositionLeft: + case ILXQtPanel::PositionTop: + drag->setHotSpot({0, 0}); + break; + case ILXQtPanel::PositionRight: + case ILXQtPanel::PositionBottom: + drag->setHotSpot(img.rect().bottomRight()); + break; + } + sDraggging = true; drag->exec(); diff --git a/plugin-taskbar/lxqttaskbutton.h b/plugin-taskbar/lxqttaskbutton.h index d083199..fc6014b 100644 --- a/plugin-taskbar/lxqttaskbutton.h +++ b/plugin-taskbar/lxqttaskbutton.h @@ -85,7 +85,6 @@ public: void refreshIconGeometry(QRect const & geom); static QString mimeDataFormat() { return QLatin1String("lxqt/lxqttaskbutton"); } - static QString mimeDataData(QMimeData const * mime); /*! \return true if this buttom received DragEnter event (and no DragLeave event yet) * */ bool hasDragAndDropHover() const; @@ -136,8 +135,8 @@ private slots: void activateWithDraggable(); signals: - void dropped(QString const & mimeWindow, QPoint const & pos); - void dragging(QString const & mimeWindow, QPoint const & pos); + void dropped(QObject * dragSource, QPoint const & pos); + void dragging(QObject * dragSource, QPoint const & pos); }; typedef QHash LXQtTaskButtonHash; diff --git a/plugin-taskbar/lxqttaskgroup.cpp b/plugin-taskbar/lxqttaskgroup.cpp index aee94d0..6828216 100644 --- a/plugin-taskbar/lxqttaskgroup.cpp +++ b/plugin-taskbar/lxqttaskgroup.cpp @@ -329,7 +329,7 @@ void LXQtTaskGroup::regroup() { QString t = QString("%1 - %2 windows").arg(mGroupName).arg(cont); setText(t); - setToolTip(parentTaskBar()->isShowGroupOnHover() ? QStringLiteral() : t); + setToolTip(parentTaskBar()->isShowGroupOnHover() ? QString() : t); setWindowId(0); } } diff --git a/plugin-volume/lxqtvolume.cpp b/plugin-volume/lxqtvolume.cpp index 7e974b4..2f0422b 100644 --- a/plugin-volume/lxqtvolume.cpp +++ b/plugin-volume/lxqtvolume.cpp @@ -155,17 +155,19 @@ void LXQtVolume::setAudioEngine(AudioEngine *engine) } m_engine = engine; - connect(m_engine, SIGNAL(sinkListChanged()), this, SLOT(updateConfigurationSinkList())); + connect(m_engine, &AudioEngine::sinkListChanged, this, &LXQtVolume::handleSinkListChanged); - updateConfigurationSinkList(); + handleSinkListChanged(); } void LXQtVolume::settingsChanged() { + m_defaultSinkIndex = settings()->value(SETTINGS_DEVICE, SETTINGS_DEFAULT_DEVICE).toInt(); QString engineName = settings()->value(SETTINGS_AUDIO_ENGINE, SETTINGS_DEFAULT_AUDIO_ENGINE).toString(); qDebug() << "settingsChanged" << engineName; - if (!m_engine || m_engine->backendName() != engineName) { + const bool new_engine = !m_engine || m_engine->backendName() != engineName; + if (new_engine) { #if defined(USE_PULSEAUDIO) && defined(USE_ALSA) if (engineName == QLatin1String("PulseAudio")) setAudioEngine(new PulseAudioEngine(this)); @@ -194,21 +196,25 @@ void LXQtVolume::settingsChanged() m_volumeButton->setMixerCommand(settings()->value(SETTINGS_MIXER_COMMAND, SETTINGS_DEFAULT_MIXER_COMMAND).toString()); m_volumeButton->volumePopup()->setSliderStep(settings()->value(SETTINGS_STEP, SETTINGS_DEFAULT_STEP).toInt()); - m_defaultSinkIndex = settings()->value(SETTINGS_DEVICE, SETTINGS_DEFAULT_DEVICE).toInt(); - if (m_engine && m_engine->sinks().count() > 0) { - m_defaultSinkIndex = qBound(0, m_defaultSinkIndex, m_engine->sinks().count()-1); - - m_defaultSink = m_engine->sinks().at(m_defaultSinkIndex); - m_volumeButton->volumePopup()->setDevice(m_defaultSink); - - m_engine->setIgnoreMaxVolume(settings()->value(SETTINGS_IGNORE_MAX_VOLUME, SETTINGS_DEFAULT_IGNORE_MAX_VOLUME).toBool()); - } + if (!new_engine) + handleSinkListChanged(); } -void LXQtVolume::updateConfigurationSinkList() +void LXQtVolume::handleSinkListChanged() { - if (m_engine && m_configDialog) - m_configDialog->setSinkList(m_engine->sinks()); + if (m_engine) + { + if (m_engine->sinks().count() > 0) + { + m_defaultSink = m_engine->sinks().at(qBound(0, m_defaultSinkIndex, m_engine->sinks().count()-1)); + m_volumeButton->volumePopup()->setDevice(m_defaultSink); + + m_engine->setIgnoreMaxVolume(settings()->value(SETTINGS_IGNORE_MAX_VOLUME, SETTINGS_DEFAULT_IGNORE_MAX_VOLUME).toBool()); + } + + if (m_configDialog) + m_configDialog->setSinkList(m_engine->sinks()); + } } void LXQtVolume::handleShortcutVolumeUp() diff --git a/plugin-volume/lxqtvolume.h b/plugin-volume/lxqtvolume.h index 32706b0..ff40c4a 100644 --- a/plugin-volume/lxqtvolume.h +++ b/plugin-volume/lxqtvolume.h @@ -62,7 +62,7 @@ public: void setAudioEngine(AudioEngine *engine); protected slots: virtual void settingsChanged(); - void updateConfigurationSinkList(); + void handleSinkListChanged(); void handleShortcutVolumeUp(); void handleShortcutVolumeDown(); void handleShortcutVolumeMute(); diff --git a/plugin-volume/pulseaudioengine.cpp b/plugin-volume/pulseaudioengine.cpp index 8f088ae..0135ffd 100644 --- a/plugin-volume/pulseaudioengine.cpp +++ b/plugin-volume/pulseaudioengine.cpp @@ -116,12 +116,10 @@ static void contextSuccessCallback(pa_context *context, int success, void *userd static void contextSubscriptionCallback(pa_context *context, pa_subscription_event_type_t t, uint32_t idx, void *userdata) { PulseAudioEngine *pulseEngine = reinterpret_cast(userdata); - foreach (AudioDevice *dev, pulseEngine->sinks()) { - if (dev->index() == idx) { - pulseEngine->requestSinkInfoUpdate(dev); - break; - } - } + if (PA_SUBSCRIPTION_EVENT_REMOVE == t) + pulseEngine->removeSink(idx); + else + pulseEngine->requestSinkInfoUpdate(idx); } @@ -171,6 +169,18 @@ PulseAudioEngine::~PulseAudioEngine() } } +void PulseAudioEngine::removeSink(uint32_t idx) +{ + auto dev_i = std::find_if(m_sinks.begin(), m_sinks.end(), [idx] (AudioDevice * dev) { return dev->index() == idx; }); + if (m_sinks.end() == dev_i) + return; + + QScopedPointer dev{*dev_i}; + m_cVolumeMap.remove(dev.data()); + m_sinks.erase(dev_i); + emit sinkListChanged(); +} + void PulseAudioEngine::addOrUpdateSink(const pa_sink_info *info) { AudioDevice *dev = 0; @@ -202,14 +212,20 @@ void PulseAudioEngine::addOrUpdateSink(const pa_sink_info *info) dev->setVolumeNoCommit(((double)v * 100.0) / m_maximumVolume); if (newSink) { - m_sinks.append(dev); + //keep the sinks sorted by index() + m_sinks.insert( + std::lower_bound(m_sinks.begin(), m_sinks.end(), dev, [] (AudioDevice const * const a, AudioDevice const * const b) { + return a->name() < b->name(); + }) + , dev + ); emit sinkListChanged(); } } -void PulseAudioEngine::requestSinkInfoUpdate(AudioDevice *device) +void PulseAudioEngine::requestSinkInfoUpdate(uint32_t idx) { - emit sinkInfoChanged(device); + emit sinkInfoChanged(idx); } void PulseAudioEngine::commitDeviceVolume(AudioDevice *device) @@ -258,7 +274,7 @@ void PulseAudioEngine::setupSubscription() if (!m_ready) return; - connect(this, SIGNAL(sinkInfoChanged(AudioDevice*)), this, SLOT(retrieveSinkInfo(AudioDevice*)), Qt::QueuedConnection); + connect(this, &PulseAudioEngine::sinkInfoChanged, this, &PulseAudioEngine::retrieveSinkInfo, Qt::QueuedConnection); pa_context_set_subscribe_callback(m_context, contextSubscriptionCallback, this); pa_threaded_mainloop_lock(m_mainLoop); @@ -349,7 +365,7 @@ void PulseAudioEngine::connectContext() } } -void PulseAudioEngine::retrieveSinkInfo(AudioDevice *device) +void PulseAudioEngine::retrieveSinkInfo(uint32_t idx) { if (!m_ready) return; @@ -357,7 +373,7 @@ void PulseAudioEngine::retrieveSinkInfo(AudioDevice *device) pa_threaded_mainloop_lock(m_mainLoop); pa_operation *operation; - operation = pa_context_get_sink_info_by_index(m_context, device->index(), sinkInfoCallback, this); + operation = pa_context_get_sink_info_by_index(m_context, idx, sinkInfoCallback, this); while (pa_operation_get_state(operation) == PA_OPERATION_RUNNING) pa_threaded_mainloop_wait(m_mainLoop); pa_operation_unref(operation); diff --git a/plugin-volume/pulseaudioengine.h b/plugin-volume/pulseaudioengine.h index bd7591a..3d5a191 100644 --- a/plugin-volume/pulseaudioengine.h +++ b/plugin-volume/pulseaudioengine.h @@ -56,7 +56,8 @@ public: int volumeMax(AudioDevice */*device*/) const { return m_maximumVolume; } - void requestSinkInfoUpdate(AudioDevice *device); + void requestSinkInfoUpdate(uint32_t idx); + void removeSink(uint32_t idx); void addOrUpdateSink(const pa_sink_info *info); pa_context_state_t contextState() const { return m_contextState; } @@ -65,13 +66,13 @@ public: public slots: void commitDeviceVolume(AudioDevice *device); - void retrieveSinkInfo(AudioDevice *device); + void retrieveSinkInfo(uint32_t idx); void setMute(AudioDevice *device, bool state); void setContextState(pa_context_state_t state); void setIgnoreMaxVolume(bool ignore); signals: - void sinkInfoChanged(AudioDevice *device); + void sinkInfoChanged(uint32_t idx); void contextStateChanged(pa_context_state_t state); void readyChanged(bool ready); diff --git a/plugin-volume/volumepopup.cpp b/plugin-volume/volumepopup.cpp index 59cf84c..c6bcd0e 100644 --- a/plugin-volume/volumepopup.cpp +++ b/plugin-volume/volumepopup.cpp @@ -106,7 +106,7 @@ void VolumePopup::handleSliderValueChanged(int value) return; // qDebug("VolumePopup::handleSliderValueChanged: %d\n", value); m_device->setVolume(value); - m_volumeSlider->setToolTip(QStringLiteral("%1%").arg(value)); + m_volumeSlider->setToolTip(QString("%1%").arg(value)); dynamic_cast(*parent()).setToolTip(m_volumeSlider->toolTip()); //parent is the button on panel QToolTip::showText(QCursor::pos(), m_volumeSlider->toolTip(), m_volumeSlider); } @@ -128,7 +128,7 @@ void VolumePopup::handleDeviceVolumeChanged(int volume) // signal emission. m_volumeSlider->blockSignals(true); m_volumeSlider->setValue(volume); - m_volumeSlider->setToolTip(QStringLiteral("%1%").arg(volume)); + m_volumeSlider->setToolTip(QString("%1%").arg(volume)); dynamic_cast(*parent()).setToolTip(m_volumeSlider->toolTip()); //parent is the button on panel m_volumeSlider->blockSignals(false);