Adding upstream version 0.9.0+20151027.
This commit is contained in:
parent
c646cdaab7
commit
161a7316cf
@ -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,18 @@ 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);
|
||||
else
|
||||
mShortcutSeq = QKeySequence(mShortcut->shortcut());
|
||||
});
|
||||
connect(mShortcut, SIGNAL(activated()), &mDelayedPopup, SLOT(start()));
|
||||
connect(mShortcut, SIGNAL(shortcutChanged(QString,QString)), this, SLOT(shortcutChanged(QString,QString)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -124,13 +133,8 @@ void LXQtMainMenu::shortcutChanged(const QString &/*oldShortcut*/, const QString
|
||||
{
|
||||
if (!newShortcut.isEmpty())
|
||||
{
|
||||
mLockCascadeChanges = true;
|
||||
|
||||
settings()->setValue("dialog/shortcut", newShortcut);
|
||||
settings()->sync();
|
||||
mShortcutSeq = QKeySequence(newShortcut);
|
||||
|
||||
mLockCascadeChanges = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -161,9 +165,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 +214,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 +290,7 @@ void LXQtMainMenu::setMenuFontSize()
|
||||
************************************************/
|
||||
QDialog *LXQtMainMenu::configureDialog()
|
||||
{
|
||||
return new LXQtMainMenuConfiguration(*settings(), DEFAULT_SHORTCUT);
|
||||
return new LXQtMainMenuConfiguration(*settings(), mShortcut, DEFAULT_SHORTCUT);
|
||||
}
|
||||
/************************************************
|
||||
|
||||
|
@ -95,7 +95,6 @@ private:
|
||||
XdgMenu mXdgMenu;
|
||||
#endif
|
||||
|
||||
bool mLockCascadeChanges;
|
||||
QTimer mDelayedPopup;
|
||||
QTimer mHideTimer;
|
||||
QKeySequence mShortcutSeq;
|
||||
|
@ -30,15 +30,17 @@
|
||||
#include "ui_lxqtmainmenuconfiguration.h"
|
||||
#include <XdgMenu>
|
||||
#include <XdgIcon>
|
||||
#include <lxqt-globalkeys.h>
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
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");
|
||||
@ -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
|
||||
@ -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()
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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())
|
||||
{
|
||||
|
@ -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<LXQtTaskGroup *>(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<LXQtTaskGroup *>(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<LXQtTaskGroup *>(sender()), mimeWindow, pos);
|
||||
connect(group, &LXQtTaskButton::dragging, this, [this] (QObject * dragSource, QPoint const & pos) {
|
||||
buttonMove(qobject_cast<LXQtTaskGroup *>(sender()), qobject_cast<LXQtTaskGroup *>(dragSource), pos);
|
||||
});
|
||||
|
||||
mLayout->addWidget(group);
|
||||
|
@ -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<QString, LXQtTaskGroup*> mGroupsHash;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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<WId,LXQtTaskButton*> LXQtTaskButtonHash;
|
||||
|
Loading…
x
Reference in New Issue
Block a user