From kde-commits Wed May 31 19:23:13 2017 From: Alexander Bikadorov Date: Wed, 31 May 2017 19:23:13 +0000 To: kde-commits Subject: [krusader] krusader/Panel: Panel: set default panel popup position to left side Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=149625860525425 Git commit 687d7fbdbe4bf68fdfc6d469ea0e554e981798ec by Alexander Bikadorov. Committed on 31/05/2017 at 18:31. Pushed by abikadorov into branch 'master'. Panel: set default panel popup position to left side I believe this is much more convenient for most layouts. + Code cleanup (including removable of setting splitter sizes twice). M +7 -6 krusader/Panel/listpanel.cpp M +5 -17 krusader/Panel/panelpopup.cpp M +1 -10 krusader/Panel/panelpopup.h https://commits.kde.org/krusader/687d7fbdbe4bf68fdfc6d469ea0e554e981798ec diff --git a/krusader/Panel/listpanel.cpp b/krusader/Panel/listpanel.cpp index ef0ebfbd..52893fb4 100644 --- a/krusader/Panel/listpanel.cpp +++ b/krusader/Panel/listpanel.cpp @@ -277,7 +277,7 @@ ListPanel::ListPanel(QWidget *parent, AbstractPanelMana= ger *manager, KConfigGrou popupBtn =3D new QToolButton(this); popupBtn->setAutoRaise(true); popupBtn->setIcon(krLoader->loadIcon("arrow-up", KIconLoader::Toolbar,= 16)); - connect(popupBtn, SIGNAL(clicked()), this, SLOT(togglePanelPopup())); + connect(popupBtn, &QToolButton::clicked, this, &ListPanel::togglePanel= Popup); popupBtn->setToolTip(i18n("Open the popup panel")); ADD_WIDGET(popupBtn); = @@ -318,7 +318,7 @@ ListPanel::ListPanel(QWidget *parent, AbstractPanelMana= ger *manager, KConfigGrou // create a splitter to hold the view and the popup splt =3D new PercentalSplitter(clientArea); splt->setChildrenCollapsible(true); - splt->setOrientation(Qt::Vertical); + splt->setOrientation(Qt::Horizontal); // expand vertical if splitter orientation is horizontal QSizePolicy sizePolicy =3D splt->sizePolicy(); sizePolicy.setVerticalPolicy(QSizePolicy::Expanding); @@ -555,15 +555,16 @@ bool ListPanel::eventFilter(QObject * watched, QEvent= * e) void ListPanel::togglePanelPopup() { if(!popup) { - popup =3D new PanelPopup(splt, isLeft(), krApp); + popup =3D new PanelPopup(splt); // fix vertical grow of splitter (and entire window) if its content // demands more space QSizePolicy sizePolicy =3D popup->sizePolicy(); sizePolicy.setVerticalPolicy(QSizePolicy::Ignored); popup->setSizePolicy(sizePolicy); - connect(this, SIGNAL(pathChanged(QUrl)), popup, SLOT(onPanelPathCh= ange(QUrl))); - connect(popup, SIGNAL(selection(QUrl)), SLOTS, SLOT(refresh(QUrl))= ); - connect(popup, SIGNAL(hideMe()), this, SLOT(togglePanelPopup())); + connect(this, &ListPanel::pathChanged, popup, &PanelPopup::onPanel= PathChange); + connect(popup, &PanelPopup::selection, SLOTS, &KRslots::refresh); + connect(popup, &PanelPopup::hideMe, this, &ListPanel::togglePanelP= opup); + splt->insertWidget(0, popup); } = if (popup->isHidden()) { diff --git a/krusader/Panel/panelpopup.cpp b/krusader/Panel/panelpopup.cpp index 9d43b583..dfce1c06 100644 --- a/krusader/Panel/panelpopup.cpp +++ b/krusader/Panel/panelpopup.cpp @@ -27,7 +27,6 @@ #include "viewactions.h" #include "../defaults.h" #include "../kicons.h" -#include "../krmainwindow.h" #include "../Dialogs/krsqueezedtextlabel.h" #include "../FileSystem/fileitem.h" #include "../FileSystem/filesystem.h" @@ -45,16 +44,11 @@ #include #include = - -PanelPopup::PanelPopup(QSplitter *parent, bool left, KrMainWindow *mainWin= dow) : QWidget(parent), - _left(left), _hidden(true), _mainWindow(mainWindow), stack(0), ima= geFilePreview(0), pjob(0), splitterSizes() +PanelPopup::PanelPopup(QWidget *parent) : QWidget(parent), stack(0), image= FilePreview(0), pjob(0) { - splitter =3D parent; QGridLayout * layout =3D new QGridLayout(this); layout->setContentsMargins(0, 0, 0, 0); = - splitterSizes << 100 << 100; - // create the label+buttons setup dataLine =3D new KrSqueezedTextLabel(this); KConfigGroup lg(krConfig, "Look&Feel"); @@ -117,8 +111,8 @@ PanelPopup::PanelPopup(QSplitter *parent, bool left, Kr= MainWindow *mainWindow) : tree->setDirOnlyMode(true); // NOTE: the F2 key press event is caught before it gets to the tree tree->setEditTriggers(QAbstractItemView::EditKeyPressed); - connect(tree, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(treeSelec= tion())); - connect(tree, SIGNAL(activated(QUrl)), this, SLOT(treeSelection())); + connect(tree, &KrFileTreeView::doubleClicked, this, &PanelPopup::treeS= election); + connect(tree, &KrFileTreeView::activated, this, &PanelPopup::treeSelec= tion); = // create the quickview part ------ imageFilePreview =3D new KImageFilePreview(stack); @@ -130,7 +124,7 @@ PanelPopup::PanelPopup(QSplitter *parent, bool left, Kr= MainWindow *mainWindow) : fileViewer =3D new PanelViewer(stack); fileViewer->setProperty("KrusaderWidgetId", QVariant(View)); stack->addWidget(fileViewer); - connect(fileViewer, SIGNAL(openUrlRequest(QUrl)), this, SLOT(handleOpe= nUrlRequest(QUrl))); + connect(fileViewer, &PanelViewer::openUrlRequest, this, &PanelPopup::h= andleOpenUrlRequest); = // create the disk usage view = @@ -138,7 +132,7 @@ PanelPopup::PanelPopup(QSplitter *parent, bool left, Kr= MainWindow *mainWindow) : diskusage->setStatusLabel(dataLine, i18n("Disk Usage:")); diskusage->setProperty("KrusaderWidgetId", QVariant(DskUsage)); stack->addWidget(diskusage); - connect(diskusage, SIGNAL(openUrlRequest(QUrl)), this, SLOT(handleOpen= UrlRequest(QUrl))); + connect(diskusage, &DiskUsageViewer::openUrlRequest, this, &PanelPopup= ::handleOpenUrlRequest); = // -------- finish the layout (General one) layout->addWidget(stack, 1, 0, 1, 5); @@ -172,18 +166,12 @@ void PanelPopup::setCurrentPage(int id) void PanelPopup::show() { QWidget::show(); - if (_hidden) - splitter->setSizes(splitterSizes); - _hidden =3D false; tabSelected(currentPage()); } = void PanelPopup::hide() { - if (!_hidden) - splitterSizes =3D splitter->sizes(); QWidget::hide(); - _hidden =3D true; if (currentPage() =3D=3D View) fileViewer->closeUrl(); if (currentPage() =3D=3D DskUsage) diskusage->closeUrl(); } diff --git a/krusader/Panel/panelpopup.h b/krusader/Panel/panelpopup.h index 8810f234..51228297 100644 --- a/krusader/Panel/panelpopup.h +++ b/krusader/Panel/panelpopup.h @@ -22,15 +22,12 @@ = // QtCore #include -// QtGui // QtWidgets #include -#include #include #include #include = -#include #include #include #include @@ -40,7 +37,6 @@ class PanelViewer; class DiskUsageViewer; class KrFileTreeView; class FileItem; -class KrMainWindow; = /** * Additional side widget showing various meta information for the current= file/directories. @@ -63,7 +59,7 @@ class PanelPopup: public QWidget }; = public: - PanelPopup(QSplitter *splitter, bool left, KrMainWindow *mainWindow); + explicit PanelPopup(QWidget *parent); ~PanelPopup(); inline int currentPage() const { return stack->currentWidget()->property("KrusaderWidgetId").toInt(= ); @@ -90,9 +86,7 @@ protected slots: protected: virtual void focusInEvent(QFocusEvent*) Q_DECL_OVERRIDE; = - bool _left; bool _hidden; - KrMainWindow *_mainWindow; QStackedWidget *stack; KImageFilePreview *imageFilePreview; KrSqueezedTextLabel *dataLine; @@ -100,11 +94,8 @@ protected: KrFileTreeView *tree; QToolButton *treeBtn, *previewBtn, *viewerBtn, *duBtn; QButtonGroup *btns; - KComboBox *quickSelectCombo; PanelViewer *fileViewer; DiskUsageViewer *diskusage; - QList splitterSizes; - QSplitter *splitter; }; = #endif