mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-24 02:42:52 +00:00
kdeplasma-addons: add label for when no profiles can be found, do not set preferred size
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
af794e5fed
commit
45c5a2d8f8
2 changed files with 18 additions and 26 deletions
|
@ -23,6 +23,7 @@
|
||||||
#include <QGraphicsLinearLayout>
|
#include <QGraphicsLinearLayout>
|
||||||
#include <Plasma/IconWidget>
|
#include <Plasma/IconWidget>
|
||||||
#include <Plasma/Separator>
|
#include <Plasma/Separator>
|
||||||
|
#include <Plasma/Label>
|
||||||
#include <Plasma/ToolButton>
|
#include <Plasma/ToolButton>
|
||||||
#include <KDirWatch>
|
#include <KDirWatch>
|
||||||
#include <KStandardDirs>
|
#include <KStandardDirs>
|
||||||
|
@ -33,7 +34,6 @@
|
||||||
|
|
||||||
// standard issue margin/spacing
|
// standard issue margin/spacing
|
||||||
static const int s_spacing = 4;
|
static const int s_spacing = 4;
|
||||||
static const QSizeF s_preferredsize = QSizeF(290, 340);
|
|
||||||
|
|
||||||
class KonsoleProfilesWidget : public QGraphicsWidget
|
class KonsoleProfilesWidget : public QGraphicsWidget
|
||||||
{
|
{
|
||||||
|
@ -46,12 +46,11 @@ private Q_SLOTS:
|
||||||
void slotProfileClicked();
|
void slotProfileClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addSpacer();
|
|
||||||
|
|
||||||
KonsoleProfilesApplet* m_konsoleprofiles;
|
KonsoleProfilesApplet* m_konsoleprofiles;
|
||||||
QGraphicsLinearLayout* m_layout;
|
QGraphicsLinearLayout* m_layout;
|
||||||
Plasma::IconWidget* m_iconwidget;
|
Plasma::IconWidget* m_iconwidget;
|
||||||
Plasma::Separator* m_separator;
|
Plasma::Separator* m_separator;
|
||||||
|
Plasma::Label* m_label;
|
||||||
QGraphicsWidget* m_spacer;
|
QGraphicsWidget* m_spacer;
|
||||||
QList<Plasma::ToolButton*> m_profilebuttons;
|
QList<Plasma::ToolButton*> m_profilebuttons;
|
||||||
KDirWatch* m_dirwatch;
|
KDirWatch* m_dirwatch;
|
||||||
|
@ -63,6 +62,7 @@ KonsoleProfilesWidget::KonsoleProfilesWidget(KonsoleProfilesApplet* konsoleprofi
|
||||||
m_layout(nullptr),
|
m_layout(nullptr),
|
||||||
m_iconwidget(nullptr),
|
m_iconwidget(nullptr),
|
||||||
m_separator(nullptr),
|
m_separator(nullptr),
|
||||||
|
m_label(nullptr),
|
||||||
m_spacer(nullptr),
|
m_spacer(nullptr),
|
||||||
m_dirwatch(nullptr)
|
m_dirwatch(nullptr)
|
||||||
{
|
{
|
||||||
|
@ -81,7 +81,11 @@ KonsoleProfilesWidget::KonsoleProfilesWidget(KonsoleProfilesApplet* konsoleprofi
|
||||||
m_separator = new Plasma::Separator(this);
|
m_separator = new Plasma::Separator(this);
|
||||||
m_layout->addItem(m_separator);
|
m_layout->addItem(m_separator);
|
||||||
|
|
||||||
addSpacer();
|
m_label = new Plasma::Label(this);
|
||||||
|
m_label->setText(i18n("No profiles available"));
|
||||||
|
m_label->setAlignment(Qt::AlignCenter);
|
||||||
|
m_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
|
m_layout->addItem(m_label);
|
||||||
|
|
||||||
setLayout(m_layout);
|
setLayout(m_layout);
|
||||||
|
|
||||||
|
@ -139,17 +143,17 @@ void KonsoleProfilesWidget::slotUpdateLayout()
|
||||||
m_layout->addItem(profilebutton);
|
m_layout->addItem(profilebutton);
|
||||||
}
|
}
|
||||||
|
|
||||||
addSpacer();
|
if (hasprofiles) {
|
||||||
adjustSize();
|
m_label->hide();
|
||||||
}
|
|
||||||
|
|
||||||
void KonsoleProfilesWidget::addSpacer()
|
|
||||||
{
|
|
||||||
Q_ASSERT(!m_spacer);
|
|
||||||
m_spacer = new QGraphicsWidget(this);
|
m_spacer = new QGraphicsWidget(this);
|
||||||
m_spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
m_spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
m_spacer->setMinimumSize(1, 1);
|
m_spacer->setMinimumSize(1, 1);
|
||||||
m_layout->addItem(m_spacer);
|
m_layout->addItem(m_spacer);
|
||||||
|
} else {
|
||||||
|
m_label->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void KonsoleProfilesWidget::slotProfileClicked()
|
void KonsoleProfilesWidget::slotProfileClicked()
|
||||||
|
@ -173,7 +177,6 @@ KonsoleProfilesApplet::KonsoleProfilesApplet(QObject *parent, const QVariantList
|
||||||
KGlobal::locale()->insertCatalog("konsoleprofiles");
|
KGlobal::locale()->insertCatalog("konsoleprofiles");
|
||||||
setAspectRatioMode(Plasma::AspectRatioMode::IgnoreAspectRatio);
|
setAspectRatioMode(Plasma::AspectRatioMode::IgnoreAspectRatio);
|
||||||
setPopupIcon("utilities-terminal");
|
setPopupIcon("utilities-terminal");
|
||||||
setPreferredSize(s_preferredsize);
|
|
||||||
m_konsoleprofileswidget = new KonsoleProfilesWidget(this);
|
m_konsoleprofileswidget = new KonsoleProfilesWidget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,13 +195,5 @@ QGraphicsWidget* KonsoleProfilesApplet::graphicsWidget()
|
||||||
return m_konsoleprofileswidget;
|
return m_konsoleprofileswidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF KonsoleProfilesApplet::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
|
|
||||||
{
|
|
||||||
if (m_konsoleprofileswidget && which == Qt::PreferredSize) {
|
|
||||||
return m_konsoleprofileswidget->preferredSize();
|
|
||||||
}
|
|
||||||
return Plasma::PopupApplet::sizeHint(which, constraint);
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "moc_konsoleprofiles.cpp"
|
#include "moc_konsoleprofiles.cpp"
|
||||||
#include "konsoleprofiles.moc"
|
#include "konsoleprofiles.moc"
|
||||||
|
|
|
@ -35,9 +35,6 @@ public:
|
||||||
// Plasma::PopupApplet reimplementations
|
// Plasma::PopupApplet reimplementations
|
||||||
QGraphicsWidget* graphicsWidget() final;
|
QGraphicsWidget* graphicsWidget() final;
|
||||||
|
|
||||||
protected:
|
|
||||||
QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint) const final;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend KonsoleProfilesWidget;
|
friend KonsoleProfilesWidget;
|
||||||
KonsoleProfilesWidget *m_konsoleprofileswidget;
|
KonsoleProfilesWidget *m_konsoleprofileswidget;
|
||||||
|
|
Loading…
Add table
Reference in a new issue