Skip to content
This repository
Browse code

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
@@ -45,7 +45,8 @@ Popup::Popup(RazorMountManager *manager, QWidget* parent):
45 45 QWidget(parent, Qt::Dialog | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::X11BypassWindowManagerHint),
46 46 mManager(manager),
47 47 mPos(0,0),
48   - mAnchor(Qt::TopLeftCorner)
  48 + mAnchor(Qt::TopLeftCorner),
  49 + mDisplayCount(0)
49 50 {
50 51 setObjectName("RazorMountPopup");
51 52 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -58,8 +59,10 @@ Popup::Popup(RazorMountManager *manager, QWidget* parent):
58 59
59 60 connect(mManager, SIGNAL(deviceAdded(RazorMountDevice*)),
60 61 this, SLOT(addItem(RazorMountDevice*)));
  62 + connect(mManager, SIGNAL(deviceRemoved(RazorMountDevice*)),
  63 + this, SLOT(removeItem(RazorMountDevice*)));
61 64
62   - mPlaceholder = new QLabel(tr("No devices connected"), this);
  65 + mPlaceholder = new QLabel(tr("No devices are available"), this);
63 66 layout()->addWidget(mPlaceholder);
64 67 mPlaceholder->hide();
65 68
@@ -77,6 +80,9 @@ MenuDiskItem *Popup::addItem(RazorMountDevice *device)
77 80 MenuDiskItem *item = new MenuDiskItem(device, this);
78 81 layout()->addWidget(item);
79 82 item->setVisible(true);
  83 + mDisplayCount++;
  84 + if (mDisplayCount != 0)
  85 + mPlaceholder->hide();
80 86 return item;
81 87 }
82 88 else
@@ -85,6 +91,16 @@ MenuDiskItem *Popup::addItem(RazorMountDevice *device)
85 91 }
86 92 }
87 93
  94 +void Popup::removeItem(RazorMountDevice *device)
  95 +{
  96 + if (MenuDiskItem::isUsableDevice(device))
  97 + {
  98 + mDisplayCount--;
  99 + if (mDisplayCount == 0)
  100 + mPlaceholder->show();
  101 + }
  102 +}
  103 +
88 104
89 105 void Popup::resizeEvent(QResizeEvent *event)
90 106 {
@@ -95,7 +111,8 @@ void Popup::resizeEvent(QResizeEvent *event)
95 111
96 112 void Popup::showEvent(QShowEvent *event)
97 113 {
98   - if ( mManager->devices().count() == 0)
  114 +// qDebug() << "DEV" << mDisplayCount << mManager->devices().count() << mManager->devices();
  115 + if (mDisplayCount == 0)
99 116 mPlaceholder->show();
100 117
101 118 QWidget::showEvent(event);
@@ -255,11 +272,7 @@ void MountButton::showHidePopup()
255 272 else
256 273 {
257 274 mPopupHideTimer.stop();
258   -
259   - if (mManager.devices().isEmpty())
260   - showMessage(tr("No devices Available."));
261   - else
262   - showPopup();
  275 + showPopup();
263 276 }
264 277 }
265 278
2  razorqt-panel/plugin-mount/mountbutton.h
@@ -59,6 +59,7 @@ class Popup: public QWidget
59 59
60 60 private slots:
61 61 MenuDiskItem *addItem(RazorMountDevice *device);
  62 + void removeItem(RazorMountDevice *device);
62 63
63 64 private:
64 65 void realign();
@@ -66,6 +67,7 @@ private slots:
66 67 QPoint mPos;
67 68 Qt::Corner mAnchor;
68 69 QLabel *mPlaceholder;
  70 + int mDisplayCount;
69 71 };
70 72
71 73

0 comments on commit d4a55a1

Please sign in to comment.
Something went wrong with that request. Please try again.