Skip to content

Commit

Permalink
add bookmark menu.(refs #78)
Browse files Browse the repository at this point in the history
  • Loading branch information
haraki committed Jun 14, 2019
1 parent 9cdfe5d commit 2d72167
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 23 deletions.
29 changes: 19 additions & 10 deletions folderform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,7 @@ void FolderForm::onDirectoryLoaded(const QString& path)
ui->folderView->setCursor(currentRootIndex);
}

ui->bookmarkToolButton->blockSignals(true);
if(Settings::getInstance()->searchBookmarkDirPath(path) >= 0)
{
ui->bookmarkToolButton->setChecked(true);
}
else
{
ui->bookmarkToolButton->setChecked(false);
}
ui->bookmarkToolButton->blockSignals(false);
checkBookmark();
}

void FolderForm::onLayoutChanged(const QList<QPersistentModelIndex> &parents/* = QList<QPersistentModelIndex>()*/, QAbstractItemModel::LayoutChangeHint hint/* = QAbstractItemModel::NoLayoutChangeHint*/)
Expand Down Expand Up @@ -421,6 +412,24 @@ int FolderForm::onBookmarkDir(bool marked)
return 0;
}

void FolderForm::checkBookmark()
{
qDebug() << "FolderForm::checkBookmark()";

const QString& currentPath = getCurrentDirPath();

ui->bookmarkToolButton->blockSignals(true);
if(Settings::getInstance()->searchBookmarkDirPath(currentPath) >= 0)
{
ui->bookmarkToolButton->setChecked(true);
}
else
{
ui->bookmarkToolButton->setChecked(false);
}
ui->bookmarkToolButton->blockSignals(false);
}

void FolderForm::refresh(bool clearSelected/* = false */)
{
if(clearSelected)
Expand Down
2 changes: 2 additions & 0 deletions folderform.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class FolderForm : public QWidget
int onSelectDir();
int onBookmarkDir(bool marked);

void checkBookmark();

void refresh(bool clearSelected = false);

Q_SIGNALS:
Expand Down
36 changes: 25 additions & 11 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,17 +372,6 @@ void MainWindow::on_actionSelectFolder_triggered()
activeFolderForm->onSelectDir();
}

void MainWindow::on_actionSelectStorageBookmark_triggered()
{
qDebug() << "MainWindow::on_actionSelectStorageBookmark_triggered()";

DoubleFolderPanel* doubleFolderPanel = ui->mainWidget->findChild<DoubleFolderPanel*>("DoubleFolderPanel");
if(doubleFolderPanel != Q_NULLPTR)
{
doubleFolderPanel->onSelectStorageBookmark();
}
}

void MainWindow::on_actionQuit_triggered()
{
qDebug() << "MainWindow::on_actionQuit_triggered()";
Expand Down Expand Up @@ -500,6 +489,31 @@ void MainWindow::on_actionAttributes_triggered()
}
}

void MainWindow::on_actionBookmark_toggled(bool arg1)
{
qDebug() << "MainWindow::on_actionBookmark_toggled()";

DoubleFolderPanel* doubleFolderPanel = ui->mainWidget->findChild<DoubleFolderPanel*>("DoubleFolderPanel");
Q_ASSERT(doubleFolderPanel != Q_NULLPTR);

FolderForm* activeFolderForm = doubleFolderPanel->getActiveFolderForm();
Q_ASSERT(activeFolderForm != Q_NULLPTR);

activeFolderForm->onBookmarkDir(arg1);
activeFolderForm->checkBookmark();
}

void MainWindow::on_actionSelectStorageBookmark_triggered()
{
qDebug() << "MainWindow::on_actionSelectStorageBookmark_triggered()";

DoubleFolderPanel* doubleFolderPanel = ui->mainWidget->findChild<DoubleFolderPanel*>("DoubleFolderPanel");
if(doubleFolderPanel != Q_NULLPTR)
{
doubleFolderPanel->onSelectStorageBookmark();
}
}

void MainWindow::on_actionPreferences_triggered()
{
qDebug() << "MainWindow::on_actionPreferences_triggered()";
Expand Down
3 changes: 2 additions & 1 deletion mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ private Q_SLOTS:
void on_actionOpenWithTextEditor_triggered();
void on_actionCreateNewFile_triggered();
void on_actionSelectFolder_triggered();
void on_actionSelectStorageBookmark_triggered();
void on_actionQuit_triggered();
void on_actionSinglePane_triggered();
void on_actionDualPane_triggered();
Expand All @@ -83,6 +82,8 @@ private Q_SLOTS:
void on_actionMakeDirectory_triggered();
void on_actionRename_triggered();
void on_actionAttributes_triggered();
void on_actionBookmark_toggled(bool arg1);
void on_actionSelectStorageBookmark_triggered();
void on_actionPreferences_triggered();
void on_actionConsole_triggered(bool checked);
void on_consoleDockWidget_visibilityChanged(bool visible);
Expand Down
29 changes: 28 additions & 1 deletion mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
<addaction name="actionCreateNewFile"/>
<addaction name="separator"/>
<addaction name="actionSelectFolder"/>
<addaction name="actionSelectStorageBookmark"/>
<addaction name="separator"/>
<addaction name="actionQuit"/>
</widget>
Expand All @@ -121,9 +120,18 @@
<addaction name="actionPreferences"/>
<addaction name="actionConsole"/>
</widget>
<widget class="QMenu" name="menuBookmark">
<property name="title">
<string>Bookmark</string>
</property>
<addaction name="actionBookmark"/>
<addaction name="actionSelectStorageBookmark"/>
<addaction name="actionEdit_Bookmark"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuView"/>
<addaction name="menuOperation"/>
<addaction name="menuBookmark"/>
<addaction name="menuOption"/>
<addaction name="menuHelp"/>
</widget>
Expand Down Expand Up @@ -391,6 +399,25 @@
<string>O</string>
</property>
</action>
<action name="actionEdit_Bookmark">
<property name="text">
<string>Edit Bookmark...</string>
</property>
<property name="shortcut">
<string>Ctrl+L</string>
</property>
</action>
<action name="actionBookmark">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Bookmark</string>
</property>
<property name="shortcut">
<string>Ctrl+M</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
Expand Down

0 comments on commit 2d72167

Please sign in to comment.