Skip to content

Commit

Permalink
Add 'check' menus
Browse files Browse the repository at this point in the history
  • Loading branch information
ambiesoft committed May 1, 2020
1 parent 7f260dd commit 7e8deac
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 24 deletions.
3 changes: 3 additions & 0 deletions History.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2020/05/01 1.21.16
Add 'check' menus

2020/04/30 1.21.15
Fixed: Error 'Expression tree is too large' when Tagged item too large
Fixed: ${Tag} showed continuous commas
Expand Down
2 changes: 1 addition & 1 deletion src/consts.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Consts
Q_CONSTEXPR char ORGANIZATION[] = "Ambiesoft";
Q_CONSTEXPR char APPDOMAIN[] = "ambiesoft.mooo.com";
Q_CONSTEXPR char APPNAME[] = "SceneExplorer";
Q_CONSTEXPR char APPVERSION[] = "1.21.15";
Q_CONSTEXPR char APPVERSION[] = "1.21.16";


Q_CONSTEXPR char KEY_STYLE[] = "style";
Expand Down
40 changes: 34 additions & 6 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,7 @@ void MainWindow::deleteTag()
delete ui->listTag->takeItem(ui->listTag->row(ti));
}

void MainWindow::checkAllTagCommon(const bool bCheck)
void MainWindow::checkAllTagCommon(const bool bCheck, const bool bSelection)
{
{
Ambiesoft::BlockedBool tb(&tagChanging_);
Expand All @@ -1860,20 +1860,40 @@ void MainWindow::checkAllTagCommon(const bool bCheck)
TagItem* ti = static_cast<TagItem*>(ui->listTag->item(i));
if(ti->IsNormalItem())
{
ti->setCheckState(bCheck ? Qt::Checked : Qt::Unchecked);
if(bSelection)
{
if(ti->isSelected())
{
ti->setCheckState(bCheck ? Qt::Checked : Qt::Unchecked);
}
}
else
{
ti->setCheckState(bCheck ? Qt::Checked : Qt::Unchecked);
}
}
}
}
itemChangedCommon();
}
void MainWindow::checkAllTag()
void MainWindow::OnCheckAllTag()
{
checkAllTagCommon(true);
}
void MainWindow::uncheckAllTag()
void MainWindow::OnUncheckAllTag()
{
checkAllTagCommon(false);
}

void MainWindow::OnCheckSelectedTag()
{
checkAllTagCommon(true, true);
}
void MainWindow::OnUncheckSelectedTag()
{
checkAllTagCommon(false, true);
}

void MainWindow::showTagContextMenu(const QPoint &pos)
{
TagItem* ti =static_cast<TagItem*>( ui->listTag->itemAt(pos));
Expand All @@ -1886,8 +1906,8 @@ void MainWindow::showTagContextMenu(const QPoint &pos)
myMenuFreeArea.addAction(ui->action_Paste);
ui->action_Paste->setEnabled(IsClipboardTagDataAvalable());
myMenuFreeArea.addSeparator();
myMenuFreeArea.addAction(tr("&Check All"), this, SLOT(checkAllTag()));
myMenuFreeArea.addAction(tr("&Uncheck All"), this, SLOT(uncheckAllTag()));
myMenuFreeArea.addAction(tr("&Check All"), this, SLOT(OnCheckAllTag()));
myMenuFreeArea.addAction(tr("&Uncheck All"), this, SLOT(OnUncheckAllTag()));

// Show context menu at handling position
myMenuFreeArea.exec(ui->listTag->mapToGlobal(pos));
Expand All @@ -1903,6 +1923,14 @@ void MainWindow::showTagContextMenu(const QPoint &pos)
myMenuItemArea.addAction(tr("&Edit"), this, SLOT(editTag()));
myMenuItemArea.addAction(tr("&Delete"), this, SLOT(deleteTag()));

myMenuItemArea.addSeparator();
myMenuItemArea.addAction(tr("Check &Selection"), this, SLOT(OnCheckSelectedTag()));
myMenuItemArea.addAction(tr("Uncheck Se&lection"), this, SLOT(OnUncheckSelectedTag()));

//myMenuItemArea.addSeparator();
myMenuItemArea.addAction(tr("&Check All"), this, SLOT(OnCheckAllTag()));
myMenuItemArea.addAction(tr("&Uncheck All"), this, SLOT(OnUncheckAllTag()));

// Show context menu at handling position
myMenuItemArea.exec(ui->listTag->mapToGlobal(pos));
}
Expand Down
11 changes: 8 additions & 3 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ class MainWindow : public QMainWindow, IMainWindow, IHistoryList
QToolButton* tbLabelSort_ = nullptr;

void on_ShowMissingClicked_common(bool nNextCheck);
void checkAllTagCommon(const bool bCheck);
void checkAllTagCommon(const bool bCheck, const bool bSelection = false);


void setFontCommon1(const QString& savekey,
Expand All @@ -378,8 +378,10 @@ class MainWindow : public QMainWindow, IMainWindow, IHistoryList
private Q_SLOTS:
void editTag();
void deleteTag();
void checkAllTag();
void uncheckAllTag();
void OnCheckAllTag();
void OnUncheckAllTag();
void OnCheckSelectedTag();
void OnUncheckSelectedTag();
void showTagContextMenu(const QPoint&);
void OnMenuStyle();
void on_action_Close_triggered();
Expand Down Expand Up @@ -782,8 +784,11 @@ public Q_SLOTS:

void OnDirectoryRemove();
void OnDirectoryRemoveMissingItems();
void CheckDirectoryCommon(const bool bCheck, const bool bSelection);
void OnDirectoryCheckAll();
void OnDirectoryUncheckAll();
void OnDirectoryCheckSelection();
void OnDirectoryUncheckSelection();
void OnDirectorySortByName();
void OnDirectoryMoveUp();
void OnDirectoryMoveDown();
Expand Down
61 changes: 47 additions & 14 deletions src/mainwindow_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ void MainWindow::onMenuDirectory_AboutToShow()
actionNoDir->setEnabled(false);
ui->menu_Directory->addAction(actionNoDir);
}

// check or uncheck all
ui->menu_Directory->addSeparator();
ui->menu_Directory->addAction(tr("&Check All"), this, SLOT(OnDirectoryCheckAll()));
ui->menu_Directory->addAction(tr("&Uncheck All"), this, SLOT(OnDirectoryUncheckAll()));
}

void MainWindow::OnUserTagTriggered()
Expand Down Expand Up @@ -240,7 +245,7 @@ void MainWindow::onMenuTag_AboutToShow()
for(int i=0; i < ui->listTag->count(); ++i)
{
TagItem* ti = static_cast<TagItem*>(ui->listTag->item(i));
if(ti->IsAllItem())
if(!ti->IsNormalItem())
continue;
bAdded=true;
QString text = ti->text();
Expand All @@ -263,7 +268,13 @@ void MainWindow::onMenuTag_AboutToShow()
actionNoDir->setEnabled(false);
ui->menu_Tag->addAction(actionNoDir);
}

// check all and uncheck all
ui->menu_Tag->addSeparator();
ui->menu_Tag->addAction(tr("&Check All"), this, SLOT(OnCheckAllTag()));
ui->menu_Tag->addAction(tr("&Uncheck All"), this, SLOT(OnUncheckAllTag()));
}

void MainWindow::onMenuTask_AboutToShow()
{
qDebug() << "gPaused" << gPaused << __FUNCTION__;
Expand Down Expand Up @@ -776,7 +787,8 @@ void MainWindow::OnDirectoryRemoveMissingItems()

itemChangedCommon(true);
}
void MainWindow::OnDirectoryCheckAll()

void MainWindow::CheckDirectoryCommon(const bool bCheck, const bool bSelection)
{
{
Ambiesoft::BlockedBool bt(&directoryChanging_, true, false);
Expand All @@ -785,27 +797,43 @@ void MainWindow::OnDirectoryCheckAll()
{
DirectoryItem* item = static_cast<DirectoryItem*>(ui->directoryWidget->item(i));
if(item->IsNormalItem())
item->setCheckState(Qt::Checked);
{
if(bSelection)
{
if(item->isSelected())
{
item->setCheckState(bCheck ? Qt::Checked : Qt::Unchecked);
}
}
else
{
item->setCheckState(bCheck ? Qt::Checked : Qt::Unchecked);
}
}
}
}

itemChangedCommon();
}

void MainWindow::OnDirectoryCheckAll()
{
CheckDirectoryCommon(true,false);
}
void MainWindow::OnDirectoryUncheckAll()
{
{
Ambiesoft::BlockedBool bt(&directoryChanging_, true, false);
CheckDirectoryCommon(false,false);
}
void MainWindow::OnDirectoryCheckSelection()
{
CheckDirectoryCommon(true,true);
}
void MainWindow::OnDirectoryUncheckSelection()
{
CheckDirectoryCommon(false,true);
}

for (int i = 0; i < ui->directoryWidget->count(); ++i)
{
DirectoryItem* item = static_cast<DirectoryItem*>(ui->directoryWidget->item(i));
if(item->IsNormalItem())
item->setCheckState(Qt::Unchecked);
}
}

itemChangedCommon();
}



Expand Down Expand Up @@ -870,6 +898,7 @@ void MainWindow::on_directoryWidget_customContextMenuRequested(const QPoint &pos
MyContextMenu menu("DirectoryWidget Context Menu",this);
menu.addEnablingAction(ui->action_AddDirectory);
menu.addEnablingAction(ui->action_Paste);

menu.addSeparator();

QAction actCheckAll(tr("&Check All"));
Expand Down Expand Up @@ -902,6 +931,10 @@ void MainWindow::on_directoryWidget_customContextMenuRequested(const QPoint &pos
menu.addEnablingAction(ui->action_ScanSelectedDirectory);
menu.addSeparator();

menu.addAction(tr("Check &Selection"), this, SLOT(OnDirectoryCheckSelection()));
menu.addAction(tr("Uncheck Se&lection"), this, SLOT(OnDirectoryUncheckSelection()));
// menu.addSeparator();

QAction actCheckAll(tr("&Check All"));
connect(&actCheckAll, SIGNAL(triggered(bool)),
this, SLOT(OnDirectoryCheckAll()));
Expand Down
8 changes: 8 additions & 0 deletions src/translations/i18n_Japanese.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,14 @@
<source>There are no directories which hold the selected video.</source>
<translation>このアイテムを含むディレクトリはありません。</translation>
</message>
<message>
<source>Check &amp;Selection</source>
<translation>選択をチェック(&amp;S)</translation>
</message>
<message>
<source>Uncheck Se&amp;lection</source>
<translation>選択をチェックしない(&amp;L)</translation>
</message>
</context>
<context>
<name>Option</name>
Expand Down

0 comments on commit 7e8deac

Please sign in to comment.