From: Marcus Eggenberger Date: Sat, 5 Jul 2008 20:14:09 +0000 (+0200) Subject: you can now lock the positions of the docks (inputline, chat monitor, topic) which... X-Git-Tag: 0.3.0~312 X-Git-Url: https://git.quassel-irc.org/?a=commitdiff_plain;h=25eb89768427a8c62f0ea776d05407db3aec2f97;p=quassel.git you can now lock the positions of the docks (inputline, chat monitor, topic) which will hide their headers --- diff --git a/src/qtui/mainwin.cpp b/src/qtui/mainwin.cpp index 4d8a943b..52699e93 100644 --- a/src/qtui/mainwin.cpp +++ b/src/qtui/mainwin.cpp @@ -130,6 +130,12 @@ void MainWin::init() { setupTopicWidget(); setupChatMonitor(); setupInputWidget(); + + QAction *toggleLockDocksAction = ui.menuViews->addAction(tr("Lock dock positions")); + toggleLockDocksAction->setCheckable(true); + connect(toggleLockDocksAction, SIGNAL(toggled(bool)), this, SLOT(lockVerticalDocks(bool))); + toggleLockDocksAction->setChecked(s.value("LockDocks", false).toBool()); + setupStatusBar(); setupSystray(); @@ -259,6 +265,14 @@ void MainWin::showManageViewsDlg() { dlg.exec(); } +void MainWin::lockVerticalDocks(bool lock) { + QList docks = findChildren(); + foreach(VerticalDock *dock, docks) { + dock->showTitle(!lock); + } + QtUiSettings().setValue("LockDocks", lock); +} + void MainWin::setupNickWidget() { // create nick dock NickListDock *nickDock = new NickListDock(tr("Nicks"), this); diff --git a/src/qtui/mainwin.h b/src/qtui/mainwin.h index 3c756293..453062fd 100644 --- a/src/qtui/mainwin.h +++ b/src/qtui/mainwin.h @@ -80,6 +80,7 @@ class MainWin : public QMainWindow { void showSettingsDlg(); void showNetworkDlg(); void showManageViewsDlg(); + void lockVerticalDocks(bool lock); void showAboutDlg(); void showDebugConsole(); diff --git a/src/qtui/verticaldock.cpp b/src/qtui/verticaldock.cpp index 28ebe682..4ac07fe4 100644 --- a/src/qtui/verticaldock.cpp +++ b/src/qtui/verticaldock.cpp @@ -29,9 +29,6 @@ VerticalDockTitle::VerticalDockTitle(QDockWidget *parent) { } -VerticalDockTitle::~VerticalDockTitle() { -} - QSize VerticalDockTitle::sizeHint() const { return QSize(10, 15); } @@ -42,7 +39,7 @@ QSize VerticalDockTitle::minimumSizeHint() const { void VerticalDockTitle::paintEvent(QPaintEvent *event) { Q_UNUSED(event); - + QPainter painter(this); if(rect().isValid() && rect().height() > minimumSizeHint().height()) { @@ -52,10 +49,11 @@ void VerticalDockTitle::paintEvent(QPaintEvent *event) { qDrawShadeLine(&painter, topLeft, bottomRight, palette()); } } - + } + // ============================== // Vertical Dock // ============================== @@ -71,9 +69,6 @@ VerticalDock::VerticalDock(QWidget *parent, Qt::WindowFlags flags) setDefaultTitleWidget(); } -VerticalDock::~VerticalDock() { -} - void VerticalDock::setDefaultTitleWidget() { QWidget *oldDockTitle = titleBarWidget(); QWidget *newDockTitle = new VerticalDockTitle(this); @@ -85,3 +80,17 @@ void VerticalDock::setDefaultTitleWidget() { if(oldDockTitle) oldDockTitle->deleteLater(); } + +void VerticalDock::showTitle(bool show) { + QWidget *oldDockTitle = titleBarWidget(); + QWidget *newDockTitle = 0; + + if(show) + newDockTitle = new VerticalDockTitle(this); + else + newDockTitle = new EmptyDockTitle(this); + + setTitleBarWidget(newDockTitle); + if(oldDockTitle) + oldDockTitle->deleteLater(); +} diff --git a/src/qtui/verticaldock.h b/src/qtui/verticaldock.h index 33e684e5..ba616ff9 100644 --- a/src/qtui/verticaldock.h +++ b/src/qtui/verticaldock.h @@ -29,23 +29,36 @@ class VerticalDockTitle : public QWidget { public: VerticalDockTitle(QDockWidget *parent); - virtual ~VerticalDockTitle(); virtual QSize sizeHint() const; virtual QSize minimumSizeHint() const; + void show(bool show_); protected: virtual void paintEvent(QPaintEvent *event); + +private: + bool _show; +}; + +class EmptyDockTitle : public QWidget { + Q_OBJECT + +public: + inline EmptyDockTitle(QDockWidget *parent) : QWidget(parent) {} + + inline virtual QSize sizeHint() const { return QSize(0,0); } }; + class VerticalDock : public QDockWidget { Q_OBJECT public: VerticalDock(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0); VerticalDock(QWidget *parent = 0, Qt::WindowFlags flags = 0); - virtual ~VerticalDock(); + void showTitle(bool show); void setDefaultTitleWidget(); };