Permalink
Browse files

fixed #484 Ugly mount plugin appearance without any mountpoints present

(cherry picked from commit d4a55a1)

Conflicts:
	razorqt-panel/plugin-mount/mountbutton.cpp
  • Loading branch information...
1 parent 29f404e commit 0e77690032d796d88eaf10b32fbc16bef31f043f @pvanek pvanek committed with amoskvin Nov 19, 2012
Showing with 24 additions and 8 deletions.
  1. +22 −8 razorqt-panel/plugin-mount/mountbutton.cpp
  2. +2 −0 razorqt-panel/plugin-mount/mountbutton.h
@@ -45,7 +45,8 @@ Popup::Popup(RazorMountManager *manager, QWidget* parent):
QWidget(parent, Qt::Dialog | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::X11BypassWindowManagerHint),
mManager(manager),
mPos(0,0),
- mAnchor(Qt::TopLeftCorner)
+ mAnchor(Qt::TopLeftCorner),
+ mDisplayCount(0)
{
setObjectName("RazorMountPopup");
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -58,8 +59,10 @@ Popup::Popup(RazorMountManager *manager, QWidget* parent):
connect(mManager, SIGNAL(deviceAdded(RazorMountDevice*)),
this, SLOT(addItem(RazorMountDevice*)));
+ connect(mManager, SIGNAL(deviceRemoved(RazorMountDevice*)),
+ this, SLOT(removeItem(RazorMountDevice*)));
- mPlaceholder = new QLabel(tr("No devices connected"), this);
+ mPlaceholder = new QLabel(tr("No devices are available"), this);
layout()->addWidget(mPlaceholder);
mPlaceholder->hide();
@@ -76,6 +79,10 @@ MenuDiskItem *Popup::addItem(RazorMountDevice *device)
{
MenuDiskItem *item = new MenuDiskItem(device, this);
layout()->addWidget(item);
+ item->setVisible(true);
+ mDisplayCount++;
+ if (mDisplayCount != 0)
+ mPlaceholder->hide();
return item;
}
else
@@ -84,6 +91,16 @@ MenuDiskItem *Popup::addItem(RazorMountDevice *device)
}
}
+void Popup::removeItem(RazorMountDevice *device)
+{
+ if (MenuDiskItem::isUsableDevice(device))
+ {
+ mDisplayCount--;
+ if (mDisplayCount == 0)
+ mPlaceholder->show();
+ }
+}
+
void Popup::resizeEvent(QResizeEvent *event)
{
@@ -94,7 +111,8 @@ void Popup::resizeEvent(QResizeEvent *event)
void Popup::showEvent(QShowEvent *event)
{
- if ( mManager->devices().count() == 0)
+// qDebug() << "DEV" << mDisplayCount << mManager->devices().count() << mManager->devices();
+ if (mDisplayCount == 0)
mPlaceholder->show();
QWidget::showEvent(event);
@@ -254,11 +272,7 @@ void MountButton::showHidePopup()
else
{
mPopupHideTimer.stop();
-
- if (mManager.devices().isEmpty())
- showMessage(tr("No devices Available."));
- else
- showPopup();
+ showPopup();
}
}
@@ -59,13 +59,15 @@ class Popup: public QWidget
private slots:
MenuDiskItem *addItem(RazorMountDevice *device);
+ void removeItem(RazorMountDevice *device);
private:
void realign();
RazorMountManager *mManager;
QPoint mPos;
Qt::Corner mAnchor;
QLabel *mPlaceholder;
+ int mDisplayCount;
};

0 comments on commit 0e77690

Please sign in to comment.