Skip to content

Commit

Permalink
Use built-in attribute to add separator between built-in and custom t…
Browse files Browse the repository at this point in the history
…hemes
  • Loading branch information
cloose committed Dec 22, 2015
1 parent 488f42b commit 2a53e01
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion app/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1176,23 +1176,37 @@ void MainWindow::updateSplitter()

void MainWindow::setupHtmlPreviewThemes()
{

ui->menuStyles->clear();

delete stylesGroup;
stylesGroup = new QActionGroup(this);

int key = 1;
bool separatorAdded = false;
foreach(const QString &themeName, themeCollection->themeNames()) {
QAction *action = ui->menuStyles->addAction(themeName);
action->setShortcut(QKeySequence(tr("Ctrl+%1").arg(key++)));
action->setCheckable(true);
action->setActionGroup(stylesGroup);
connect(action, &QAction::triggered,
this, &MainWindow::themeChanged);

if (!separatorAdded && !themeCollection->theme(themeName).isBuiltIn()) {
addSeparatorAfterBuiltInThemes();
separatorAdded = true;
}
}
}

void MainWindow::addSeparatorAfterBuiltInThemes()
{
ui->menuStyles->addSeparator();

QAction *separator = new QAction(stylesGroup);
separator->setSeparator(true);
stylesGroup->addAction(separator);
}

void MainWindow::loadCustomStyles()
{
QStringList paths = DataLocation::standardLocations();
Expand Down
1 change: 1 addition & 0 deletions app/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ private slots:
void setFileName(const QString &fileName);
void updateSplitter();
void setupHtmlPreviewThemes();
void addSeparatorAfterBuiltInThemes();
void loadCustomStyles();
void readSettings();
void writeSettings();
Expand Down

0 comments on commit 2a53e01

Please sign in to comment.