mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
kdeplasma-addons: set konsoleprofiles applet preferred size based on form factor
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
183876c0c6
commit
cbc029d43c
2 changed files with 25 additions and 1 deletions
|
@ -28,10 +28,12 @@
|
|||
#include <KStandardDirs>
|
||||
#include <KIcon>
|
||||
#include <KToolInvocation>
|
||||
#include <KIconLoader>
|
||||
#include <KDebug>
|
||||
|
||||
// standard issue margin/spacing
|
||||
static const int s_spacing = 4;
|
||||
static const QSizeF s_preferredsize = QSizeF(290, 340);
|
||||
|
||||
class KonsoleProfilesWidget : public QGraphicsWidget
|
||||
{
|
||||
|
@ -171,7 +173,7 @@ KonsoleProfilesApplet::KonsoleProfilesApplet(QObject *parent, const QVariantList
|
|||
KGlobal::locale()->insertCatalog("konsoleprofiles");
|
||||
setAspectRatioMode(Plasma::AspectRatioMode::IgnoreAspectRatio);
|
||||
setPopupIcon("utilities-terminal");
|
||||
setPreferredSize(290, 340);
|
||||
setPreferredSize(s_preferredsize);
|
||||
m_konsoleprofileswidget = new KonsoleProfilesWidget(this);
|
||||
}
|
||||
|
||||
|
@ -190,5 +192,23 @@ QGraphicsWidget* KonsoleProfilesApplet::graphicsWidget()
|
|||
return m_konsoleprofileswidget;
|
||||
}
|
||||
|
||||
void KonsoleProfilesApplet::constraintsEvent(Plasma::Constraints constraints)
|
||||
{
|
||||
if (constraints & Plasma::FormFactorConstraint) {
|
||||
switch (formFactor()) {
|
||||
case Plasma::FormFactor::Horizontal:
|
||||
case Plasma::FormFactor::Vertical: {
|
||||
const int paneliconsize = KIconLoader::global()->currentSize(KIconLoader::Panel);
|
||||
setPreferredSize(QSizeF(paneliconsize, paneliconsize));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
setPreferredSize(s_preferredsize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_konsoleprofiles.cpp"
|
||||
#include "konsoleprofiles.moc"
|
||||
|
|
|
@ -35,6 +35,10 @@ public:
|
|||
// Plasma::PopupApplet reimplementation
|
||||
QGraphicsWidget* graphicsWidget() final;
|
||||
|
||||
protected:
|
||||
// Plasma::Applet reimplementation
|
||||
void constraintsEvent(Plasma::Constraints constraints) final;
|
||||
|
||||
private:
|
||||
friend KonsoleProfilesWidget;
|
||||
KonsoleProfilesWidget *m_konsoleprofileswidget;
|
||||
|
|
Loading…
Add table
Reference in a new issue