aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Wenninger <jowenn@kde.org>2014-01-21 21:18:08 (GMT)
committerJoseph Wenninger <jowenn@kde.org>2014-01-21 21:18:08 (GMT)
commit66e417c8fa9c1ae45b456e891afde32ca7a8605b (patch)
tree5cb0ba9cf5ab7f409f8d39bdb0bedb45d4361f0b
parent10b6360da8ac1f9bc25f22f66db2402e919bad38 (diff)
replacement for not existing delayed menu in QPushButton. Future feature in menu, but not yet there
-rw-r--r--kate/session/katesessionchooser.cpp32
-rw-r--r--kate/session/katesessionchooser.h3
2 files changed, 28 insertions, 7 deletions
diff --git a/kate/session/katesessionchooser.cpp b/kate/session/katesessionchooser.cpp
index 9b16ab3..5bbd98a 100644
--- a/kate/session/katesessionchooser.cpp
+++ b/kate/session/katesessionchooser.cpp
@@ -32,6 +32,8 @@
#include <QMenu>
#include <QPushButton>
#include <QVBoxLayout>
+#include <QPushButton>
+#include <QHeaderView>
//BEGIN CHOOSER DIALOG
@@ -47,7 +49,12 @@ KateSessionChooser::KateSessionChooser (QWidget *parent, const QString &lastSess
QStringList header;
header << i18n("Session Name");
header << i18nc("The number of open documents", "Open Documents");
+ header << QString();
m_sessions->setHeaderLabels(header);
+ m_sessions->header()->setStretchLastSection(false);
+ m_sessions->header()->resizeSection(0,(m_sessions->size().width()-32)*2/3);
+ m_sessions->header()->resizeSection(1,(m_sessions->size().width()-32)/3);
+ m_sessions->header()->resizeSection(2,32);
m_sessions->setRootIsDecorated( false );
m_sessions->setItemsExpandable( false );
m_sessions->setAllColumnsShowFocus( true );
@@ -61,7 +68,15 @@ KateSessionChooser::KateSessionChooser (QWidget *parent, const QString &lastSess
foreach(const KateSession::Ptr &session, slist) {
KateSessionChooserItem *item = new KateSessionChooserItem (m_sessions, session);
-
+ QPushButton *tmp=new QPushButton(QIcon::fromTheme(QStringLiteral("")),QString(),m_sessions);
+ QMenu* popup = new QMenu(this);
+ QAction *a = popup->addAction(i18n("New cloned session"));
+ a->setData(QVariant::fromValue((void*)item));
+ connect(a, SIGNAL(triggered()), this, SLOT(slotCopySession()));
+ a=popup->addAction(i18n("Delete session"));
+ tmp->setMenu(popup);
+ m_sessions->setItemWidget (item, 2, tmp );
+
if (session->name() == lastSession) {
m_sessions->setCurrentItem (item);
}
@@ -94,25 +109,28 @@ KateSessionChooser::KateSessionChooser (QWidget *parent, const QString &lastSess
buttonBox->addButton(m_openButton, QDialogButtonBox::ActionRole);
connect(m_openButton, SIGNAL(clicked()), this, SLOT(slotOpen()));
- QMenu* popup = new QMenu(this);
- m_openButton->setMenu(popup); // KF5 FIXME: setDelayedMenu is not supported by QPushButton
- QAction *a = popup->addAction(i18n("Use selected session as template"));
- connect(a, SIGNAL(triggered()), this, SLOT(slotCopySession()));
-
QPushButton *newButton = new QPushButton(QIcon::fromTheme(QStringLiteral("document-new")), i18n("New Session"));
buttonBox->addButton(newButton, QDialogButtonBox::ActionRole);
connect(newButton, SIGNAL(clicked()), this, SLOT(slotNew()));
setResult (resultNone);
- m_sessions->resizeColumnToContents(0);
+ //m_sessions->resizeColumnToContents(0);
selectionChanged (NULL, NULL);
}
+void KateSessionChooser::resizeEvent(QResizeEvent * event)
+{
+ m_sessions->header()->resizeSection(0,(m_sessions->size().width()-32)*2/3);
+ m_sessions->header()->resizeSection(1,(m_sessions->size().width()-32)/3);
+ m_sessions->header()->resizeSection(2,32);
+}
+
KateSessionChooser::~KateSessionChooser ()
{}
void KateSessionChooser::slotCopySession()
{
+ m_sessions->setCurrentItem( (KateSessionChooserItem*) ((QAction*)sender())->data().value<void*>() );
Q_ASSERT(static_cast<KateSessionChooserItem *>(m_sessions->currentItem()));
done(resultCopy);
}
diff --git a/kate/session/katesessionchooser.h b/kate/session/katesessionchooser.h
index 5d536f2..8c88c77 100644
--- a/kate/session/katesessionchooser.h
+++ b/kate/session/katesessionchooser.h
@@ -60,6 +60,9 @@ class KateSessionChooser : public QDialog
*/
void selectionChanged (QTreeWidgetItem *current, QTreeWidgetItem *previous);
+ protected:
+ void resizeEvent(QResizeEvent * event);
+
private:
QTreeWidget *m_sessions;
QCheckBox *m_useLast;