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 settings;
|
||||||
settings.beginGroup("Bookmarks");
|
settings.beginGroup("Bookmarks");
|
||||||
m_showMostVisited = settings.value("showMostVisited", true).toBool();
|
m_showMostVisited = settings.value("showMostVisited", true).toBool();
|
||||||
|
m_showOnlyIconsInToolbar = settings.value("showOnlyIconsInToolbar", false).toBool();
|
||||||
m_lastFolder = settings.value("LastFolder", "unsorted").toString();
|
m_lastFolder = settings.value("LastFolder", "unsorted").toString();
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
@ -51,6 +52,15 @@ void BookmarksModel::setShowingMostVisited(bool state)
|
|||||||
m_showMostVisited = 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)
|
void BookmarksModel::setLastFolder(const QString &folder)
|
||||||
{
|
{
|
||||||
Settings settings;
|
Settings settings;
|
||||||
|
@ -57,9 +57,13 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
inline bool isShowingMostVisited() { return m_showMostVisited; }
|
|
||||||
|
bool isShowingMostVisited() { return m_showMostVisited; }
|
||||||
void setShowingMostVisited(bool state);
|
void setShowingMostVisited(bool state);
|
||||||
|
|
||||||
|
bool isShowingOnlyIconsInToolbar() { return m_showOnlyIconsInToolbar; }
|
||||||
|
void setShowingOnlyIconsInToolbar(bool state);
|
||||||
|
|
||||||
QString lastFolder() { return m_lastFolder; }
|
QString lastFolder() { return m_lastFolder; }
|
||||||
void setLastFolder(const QString &folder);
|
void setLastFolder(const QString &folder);
|
||||||
|
|
||||||
@ -108,6 +112,7 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_showMostVisited;
|
bool m_showMostVisited;
|
||||||
|
bool m_showOnlyIconsInToolbar;
|
||||||
QString m_lastFolder;
|
QString m_lastFolder;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,8 +52,8 @@ BookmarksToolbar::BookmarksToolbar(QupZilla* mainClass, QWidget* parent)
|
|||||||
|
|
||||||
setMaximumWidth(p_QupZilla->width());
|
setMaximumWidth(p_QupZilla->width());
|
||||||
|
|
||||||
// QTimer::singleShot(0, this, SLOT(refreshBookmarks()));
|
|
||||||
refreshBookmarks();
|
refreshBookmarks();
|
||||||
|
showOnlyIconsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookmarksToolbar::customContextMenuRequested(const QPoint &pos)
|
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(tr("Bookmark &All Tabs"), p_QupZilla, SLOT(bookmarkAllTabs()));
|
||||||
menu.addAction(IconProvider::fromTheme("user-bookmarks"), tr("&Organize Bookmarks"), p_QupZilla, SLOT(showBookmarksManager()));
|
menu.addAction(IconProvider::fromTheme("user-bookmarks"), tr("&Organize Bookmarks"), p_QupZilla, SLOT(showBookmarksManager()));
|
||||||
menu.addSeparator();
|
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()));
|
menu.addAction(tr("&Hide Toolbar"), this, SLOT(hidePanel()));
|
||||||
|
|
||||||
//Prevent choosing first option with double rightclick
|
//Prevent choosing first option with double rightclick
|
||||||
@ -246,6 +256,12 @@ void BookmarksToolbar::hidePanel()
|
|||||||
p_QupZilla->showBookmarksToolbar();
|
p_QupZilla->showBookmarksToolbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BookmarksToolbar::toggleShowOnlyIcons()
|
||||||
|
{
|
||||||
|
m_bookmarksModel->setShowingOnlyIconsInToolbar(!m_bookmarksModel->isShowingOnlyIconsInToolbar());
|
||||||
|
showOnlyIconsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void BookmarksToolbar::loadClickedBookmark()
|
void BookmarksToolbar::loadClickedBookmark()
|
||||||
{
|
{
|
||||||
ToolButton* button = qobject_cast<ToolButton*>(sender());
|
ToolButton* button = qobject_cast<ToolButton*>(sender());
|
||||||
@ -565,6 +581,23 @@ void BookmarksToolbar::dragEnterEvent(QDragEnterEvent* e)
|
|||||||
QWidget::dropEvent(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)
|
void BookmarksToolbar::dropEvent(QDropEvent* e)
|
||||||
{
|
{
|
||||||
const QMimeData* mime = e->mimeData();
|
const QMimeData* mime = e->mimeData();
|
||||||
|
@ -62,6 +62,7 @@ private slots:
|
|||||||
void removeButton();
|
void removeButton();
|
||||||
|
|
||||||
void hidePanel();
|
void hidePanel();
|
||||||
|
void toggleShowOnlyIcons();
|
||||||
|
|
||||||
void addBookmark(const BookmarksModel::Bookmark &bookmark);
|
void addBookmark(const BookmarksModel::Bookmark &bookmark);
|
||||||
void removeBookmark(const BookmarksModel::Bookmark &bookmark);
|
void removeBookmark(const BookmarksModel::Bookmark &bookmark);
|
||||||
@ -74,6 +75,7 @@ private:
|
|||||||
void dropEvent(QDropEvent* e);
|
void dropEvent(QDropEvent* e);
|
||||||
void dragEnterEvent(QDragEnterEvent* e);
|
void dragEnterEvent(QDragEnterEvent* e);
|
||||||
|
|
||||||
|
void showOnlyIconsChanged();
|
||||||
int indexOfLastBookmark();
|
int indexOfLastBookmark();
|
||||||
|
|
||||||
QupZilla* p_QupZilla;
|
QupZilla* p_QupZilla;
|
||||||
|
Loading…
Reference in New Issue
Block a user