mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Option to show only icons in bookmarks toolbar.
- available from bookmarks toolbar context menu Closes #251
This commit is contained in:
parent
164166282c
commit
78993c30d4
@ -38,6 +38,7 @@ void BookmarksModel::loadSettings()
|
||||
Settings settings;
|
||||
settings.beginGroup("Bookmarks");
|
||||
m_showMostVisited = settings.value("showMostVisited", true).toBool();
|
||||
m_showOnlyIconsInToolbar = settings.value("showOnlyIconsInToolbar", false).toBool();
|
||||
m_lastFolder = settings.value("LastFolder", "unsorted").toString();
|
||||
settings.endGroup();
|
||||
}
|
||||
@ -51,6 +52,15 @@ void BookmarksModel::setShowingMostVisited(bool state)
|
||||
m_showMostVisited = state;
|
||||
}
|
||||
|
||||
void BookmarksModel::setShowingOnlyIconsInToolbar(bool state)
|
||||
{
|
||||
Settings settings;
|
||||
settings.beginGroup("Bookmarks");
|
||||
settings.setValue("showOnlyIconsInToolbar", state);
|
||||
settings.endGroup();
|
||||
m_showOnlyIconsInToolbar = state;
|
||||
}
|
||||
|
||||
void BookmarksModel::setLastFolder(const QString &folder)
|
||||
{
|
||||
Settings settings;
|
||||
|
@ -57,9 +57,13 @@ public:
|
||||
};
|
||||
|
||||
void loadSettings();
|
||||
inline bool isShowingMostVisited() { return m_showMostVisited; }
|
||||
|
||||
bool isShowingMostVisited() { return m_showMostVisited; }
|
||||
void setShowingMostVisited(bool state);
|
||||
|
||||
bool isShowingOnlyIconsInToolbar() { return m_showOnlyIconsInToolbar; }
|
||||
void setShowingOnlyIconsInToolbar(bool state);
|
||||
|
||||
QString lastFolder() { return m_lastFolder; }
|
||||
void setLastFolder(const QString &folder);
|
||||
|
||||
@ -108,6 +112,7 @@ public slots:
|
||||
|
||||
private:
|
||||
bool m_showMostVisited;
|
||||
bool m_showOnlyIconsInToolbar;
|
||||
QString m_lastFolder;
|
||||
};
|
||||
|
||||
|
@ -52,8 +52,8 @@ BookmarksToolbar::BookmarksToolbar(QupZilla* mainClass, QWidget* parent)
|
||||
|
||||
setMaximumWidth(p_QupZilla->width());
|
||||
|
||||
// QTimer::singleShot(0, this, SLOT(refreshBookmarks()));
|
||||
refreshBookmarks();
|
||||
showOnlyIconsChanged();
|
||||
}
|
||||
|
||||
void BookmarksToolbar::customContextMenuRequested(const QPoint &pos)
|
||||
@ -65,7 +65,17 @@ void BookmarksToolbar::customContextMenuRequested(const QPoint &pos)
|
||||
menu.addAction(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs()));
|
||||
menu.addAction(IconProvider::fromTheme("user-bookmarks"), tr("&Organize Bookmarks"), p_QupZilla, SLOT(showBookmarksManager()));
|
||||
menu.addSeparator();
|
||||
menu.addAction(m_bookmarksModel->isShowingMostVisited() ? tr("Hide Most &Visited") : tr("Show Most &Visited"), this, SLOT(showMostVisited()));
|
||||
QAction act(tr("Show Most &Visited"), this);
|
||||
act.setCheckable(true);
|
||||
act.setChecked(m_bookmarksModel->isShowingMostVisited());
|
||||
connect(&act, SIGNAL(triggered()), this, SLOT(showMostVisited()));
|
||||
menu.addAction(&act);
|
||||
QAction act2(tr("Show Only Icons"), this);
|
||||
act2.setCheckable(true);
|
||||
act2.setChecked(m_bookmarksModel->isShowingOnlyIconsInToolbar());
|
||||
connect(&act2, SIGNAL(triggered()), this, SLOT(toggleShowOnlyIcons()));
|
||||
menu.addAction(&act2);
|
||||
menu.addSeparator();
|
||||
menu.addAction(tr("&Hide Toolbar"), this, SLOT(hidePanel()));
|
||||
|
||||
//Prevent choosing first option with double rightclick
|
||||
@ -246,6 +256,12 @@ void BookmarksToolbar::hidePanel()
|
||||
p_QupZilla->showBookmarksToolbar();
|
||||
}
|
||||
|
||||
void BookmarksToolbar::toggleShowOnlyIcons()
|
||||
{
|
||||
m_bookmarksModel->setShowingOnlyIconsInToolbar(!m_bookmarksModel->isShowingOnlyIconsInToolbar());
|
||||
showOnlyIconsChanged();
|
||||
}
|
||||
|
||||
void BookmarksToolbar::loadClickedBookmark()
|
||||
{
|
||||
ToolButton* button = qobject_cast<ToolButton*>(sender());
|
||||
@ -565,6 +581,23 @@ void BookmarksToolbar::dragEnterEvent(QDragEnterEvent* e)
|
||||
QWidget::dropEvent(e);
|
||||
}
|
||||
|
||||
void BookmarksToolbar::showOnlyIconsChanged()
|
||||
{
|
||||
Qt::ToolButtonStyle iconStyle = Qt::ToolButtonTextBesideIcon;
|
||||
if (m_bookmarksModel->isShowingOnlyIconsInToolbar()) {
|
||||
iconStyle = Qt::ToolButtonIconOnly;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_layout->count(); ++i) {
|
||||
ToolButton* button = qobject_cast<ToolButton*>(m_layout->itemAt(i)->widget());
|
||||
if (!button) {
|
||||
continue;
|
||||
}
|
||||
|
||||
button->setToolButtonStyle(iconStyle);
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarksToolbar::dropEvent(QDropEvent* e)
|
||||
{
|
||||
const QMimeData* mime = e->mimeData();
|
||||
|
@ -62,6 +62,7 @@ private slots:
|
||||
void removeButton();
|
||||
|
||||
void hidePanel();
|
||||
void toggleShowOnlyIcons();
|
||||
|
||||
void addBookmark(const BookmarksModel::Bookmark &bookmark);
|
||||
void removeBookmark(const BookmarksModel::Bookmark &bookmark);
|
||||
@ -74,6 +75,7 @@ private:
|
||||
void dropEvent(QDropEvent* e);
|
||||
void dragEnterEvent(QDragEnterEvent* e);
|
||||
|
||||
void showOnlyIconsChanged();
|
||||
int indexOfLastBookmark();
|
||||
|
||||
QupZilla* p_QupZilla;
|
||||
|
Loading…
Reference in New Issue
Block a user