Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed #484 Ugly mount plugin appearance without any mountpoints present

  • Loading branch information...
commit d4a55a1b0da5b5abc71885751e5a24ada5419e08 1 parent ea8b41f
Petr Vanek pvanek authored
29 razorqt-panel/plugin-mount/mountbutton.cpp
View
@@ -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();
@@ -77,6 +80,9 @@ 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
@@ -85,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)
{
@@ -95,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);
@@ -255,11 +272,7 @@ void MountButton::showHidePopup()
else
{
mPopupHideTimer.stop();
-
- if (mManager.devices().isEmpty())
- showMessage(tr("No devices Available."));
- else
- showPopup();
+ showPopup();
}
}
2  razorqt-panel/plugin-mount/mountbutton.h
View
@@ -59,6 +59,7 @@ class Popup: public QWidget
private slots:
MenuDiskItem *addItem(RazorMountDevice *device);
+ void removeItem(RazorMountDevice *device);
private:
void realign();
@@ -66,6 +67,7 @@ private slots:
QPoint mPos;
Qt::Corner mAnchor;
QLabel *mPlaceholder;
+ int mDisplayCount;
};
Please sign in to comment.
Something went wrong with that request. Please try again.