New corner/status buttons.
This commit is contained in:
parent
0ceec084b2
commit
29664caf9d
5 changed files with 58 additions and 33 deletions
|
@ -11,6 +11,7 @@ Added:
|
|||
Changed:
|
||||
<ul>
|
||||
<li>Tab order and default widget changed for category/feed add/edit dialogs.</li>
|
||||
<li>New style for tab widget corner buttons.</li>
|
||||
</ul>
|
||||
|
||||
<hr/>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <QStyleOption>
|
||||
|
||||
|
||||
PlainToolButton::PlainToolButton(QWidget *parent) : QToolButton(parent) {
|
||||
PlainToolButton::PlainToolButton(QWidget *parent) : QToolButton(parent), m_padding(0) {
|
||||
}
|
||||
|
||||
PlainToolButton::~PlainToolButton() {
|
||||
|
@ -36,9 +36,24 @@ void PlainToolButton::paintEvent(QPaintEvent *e) {
|
|||
QPainter p(this);
|
||||
QRect rect(QPoint(0, 0), size());
|
||||
|
||||
// TODO: adjustable "padding" of the icon.
|
||||
//rect.adjust(2, 2, -2, -2);
|
||||
// Set padding.
|
||||
rect.adjust(m_padding, m_padding, -m_padding, -m_padding);
|
||||
|
||||
// Paint the icon.
|
||||
if (underMouse()) {
|
||||
p.setOpacity(0.7);
|
||||
}
|
||||
|
||||
icon().paint(&p, rect);
|
||||
}
|
||||
|
||||
int PlainToolButton::padding() const {
|
||||
return m_padding;
|
||||
}
|
||||
|
||||
void PlainToolButton::setPadding(int padding) {
|
||||
m_padding = padding;
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,9 +29,16 @@ class PlainToolButton : public QToolButton {
|
|||
explicit PlainToolButton(QWidget *parent = 0);
|
||||
virtual ~PlainToolButton();
|
||||
|
||||
// Padding changers.
|
||||
int padding() const;
|
||||
void setPadding(int padding);
|
||||
|
||||
protected:
|
||||
// Custom look.
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
private:
|
||||
int m_padding;
|
||||
};
|
||||
|
||||
#endif // CLOSEBUTTON_H
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <QToolButton>
|
||||
|
||||
|
||||
TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent), m_mainMenu(NULL) {
|
||||
TabWidget::TabWidget(QWidget *parent) : QTabWidget(parent), m_menuMain(NULL) {
|
||||
setTabBar(new TabBar(this));
|
||||
setupCornerButton();
|
||||
setupMainMenuButton();
|
||||
|
@ -44,46 +44,48 @@ TabWidget::~TabWidget() {
|
|||
}
|
||||
|
||||
void TabWidget::setupCornerButton() {
|
||||
m_cornerButton = new PlainToolButton(this);
|
||||
m_cornerButton->setAutoRaise(true);
|
||||
m_cornerButton->setToolTip(tr("Open new web browser tab."));
|
||||
m_cornerButton->setIcon(IconThemeFactory::instance()->fromTheme("list-add"));
|
||||
m_btnAddTab = new PlainToolButton(this);
|
||||
m_btnAddTab->setAutoRaise(true);
|
||||
m_btnAddTab->setPadding(3);
|
||||
m_btnAddTab->setToolTip(tr("Open new web browser tab."));
|
||||
m_btnAddTab->setIcon(IconThemeFactory::instance()->fromTheme("list-add"));
|
||||
|
||||
connect(m_cornerButton, SIGNAL(clicked()), this, SLOT(addEmptyBrowser()));
|
||||
connect(m_btnAddTab, SIGNAL(clicked()), this, SLOT(addEmptyBrowser()));
|
||||
|
||||
setCornerWidget(m_cornerButton, Qt::TopRightCorner);
|
||||
setCornerWidget(m_btnAddTab, Qt::TopRightCorner);
|
||||
}
|
||||
|
||||
void TabWidget::setupMainMenuButton() {
|
||||
m_menuButton = new PlainToolButton(this);
|
||||
m_menuButton->setAutoRaise(true);
|
||||
m_menuButton->setToolTip(tr("Displays main menu."));
|
||||
m_menuButton->setIcon(IconThemeFactory::instance()->fromTheme("application-menu"));
|
||||
m_menuButton->setPopupMode(QToolButton::InstantPopup);
|
||||
m_btnMainMenu = new PlainToolButton(this);
|
||||
m_btnMainMenu->setAutoRaise(true);
|
||||
m_btnMainMenu->setPadding(3);
|
||||
m_btnMainMenu->setToolTip(tr("Displays main menu."));
|
||||
m_btnMainMenu->setIcon(IconThemeFactory::instance()->fromTheme("application-menu"));
|
||||
m_btnMainMenu->setPopupMode(QToolButton::InstantPopup);
|
||||
|
||||
connect(m_menuButton, SIGNAL(clicked()), this, SLOT(openMainMenu()));
|
||||
connect(m_btnMainMenu, SIGNAL(clicked()), this, SLOT(openMainMenu()));
|
||||
|
||||
setCornerWidget(m_menuButton, Qt::TopLeftCorner);
|
||||
setCornerWidget(m_btnMainMenu, Qt::TopLeftCorner);
|
||||
}
|
||||
|
||||
void TabWidget::openMainMenu() {
|
||||
if (m_mainMenu == NULL) {
|
||||
m_mainMenu = new QMenu(tr("Main menu"), this);
|
||||
m_mainMenu->addMenu(FormMain::instance()->m_ui->m_menuFile);
|
||||
m_mainMenu->addMenu(FormMain::instance()->m_ui->m_menuView);
|
||||
m_mainMenu->addMenu(FormMain::instance()->m_ui->m_menuFeeds);
|
||||
m_mainMenu->addMenu(FormMain::instance()->m_ui->m_menuMessages);
|
||||
m_mainMenu->addMenu(FormMain::instance()->m_ui->m_menuTools);
|
||||
m_mainMenu->addMenu(FormMain::instance()->m_ui->m_menuHelp);
|
||||
if (m_menuMain == NULL) {
|
||||
m_menuMain = new QMenu(tr("Main menu"), this);
|
||||
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuFile);
|
||||
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuView);
|
||||
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuFeeds);
|
||||
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuMessages);
|
||||
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuTools);
|
||||
m_menuMain->addMenu(FormMain::instance()->m_ui->m_menuHelp);
|
||||
}
|
||||
|
||||
QPoint button_position = m_menuButton->pos();
|
||||
QSize target_size = m_menuButton->size() / 2.0;
|
||||
QPoint button_position = m_btnMainMenu->pos();
|
||||
QSize target_size = m_btnMainMenu->size() / 2.0;
|
||||
|
||||
button_position.setX(button_position.x() + target_size.width());
|
||||
button_position.setY(button_position.y() + target_size.height());
|
||||
|
||||
m_mainMenu->exec(mapToGlobal(button_position));
|
||||
m_menuMain->exec(mapToGlobal(button_position));
|
||||
}
|
||||
|
||||
void TabWidget::checkTabBarVisibility() {
|
||||
|
@ -139,7 +141,7 @@ void TabWidget::setupIcons() {
|
|||
}
|
||||
|
||||
// Setup corner button icon.
|
||||
m_cornerButton->setIcon(IconThemeFactory::instance()->fromTheme("list-add"));
|
||||
m_btnAddTab->setIcon(IconThemeFactory::instance()->fromTheme("list-add"));
|
||||
}
|
||||
|
||||
bool TabWidget::closeTab(int index) {
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
|
||||
class QMenu;
|
||||
class QToolButton;
|
||||
class PlainToolButton;
|
||||
class Message;
|
||||
class FeedMessageViewer;
|
||||
|
||||
|
@ -124,9 +124,9 @@ class TabWidget : public QTabWidget {
|
|||
const QUrl &initial_url = QUrl());
|
||||
|
||||
private:
|
||||
QToolButton *m_cornerButton;
|
||||
QToolButton *m_menuButton;
|
||||
QMenu *m_mainMenu;
|
||||
PlainToolButton *m_btnAddTab;
|
||||
PlainToolButton *m_btnMainMenu;
|
||||
QMenu *m_menuMain;
|
||||
FeedMessageViewer *m_feedMessageViewer;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue