[education/rkward/devel/workspace_output] rkward/windows: Add UI action to set active output.
Thomas Friedrichsmeier
null at kde.org
Sat Mar 5 08:07:43 GMT 2022
Git commit 5cb5a12e89783891b23d6191f4a424000f6469e7 by Thomas Friedrichsmeier.
Committed on 05/03/2022 at 08:07.
Pushed by tfry into branch 'devel/workspace_output'.
Add UI action to set active output.
M +26 -10 rkward/windows/rkhtmlwindow.cpp
M +2 -0 rkward/windows/rkhtmlwindow.h
M +2 -1 rkward/windows/rkoutputwindow.rc
https://invent.kde.org/education/rkward/commit/5cb5a12e89783891b23d6191f4a424000f6469e7
diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index 01a4286a..95ef2f10 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -442,6 +442,12 @@ void RKHTMLWindow::slotRevert() {
dir->revert();
}
+void RKHTMLWindow::slotActivate() {
+ RK_TRACE (APP);
+ RK_ASSERT(dir);
+ dir->activate();
+}
+
void RKHTMLWindow::openLocationFromHistory (VisitedLocation &loc) {
RK_TRACE (APP);
RK_ASSERT (window_mode == HTMLHelpWindow);
@@ -704,8 +710,7 @@ void RKHTMLWindow::updateCaption (const QUrl &url) {
if (window_mode == HTMLOutputWindow) {
if (dir) {
- QString name = QFileInfo(dir->filename()).fileName();
- if (name.isEmpty()) name = i18n("Unnamed");
+ QString name = dir->caption();
QString mods;
if (dir->isActive()) mods.append(i18n("[Active]"));
// TODO: use icon(s), instead
@@ -901,7 +906,12 @@ void RKHTMLWindowPart::initActions () {
revert = actionCollection()->addAction("output_revert", window, SLOT(slotRevert()));
revert->setText(i18n("&Revert to last saved state"));
- revert->setIcon (QIcon::fromTheme("edit-undo"));
+ revert->setIcon(QIcon::fromTheme("edit-undo"));
+
+ activate = actionCollection()->addAction("output_activate", window, SLOT(slotActivate()));
+ activate->setText(i18n("Set Output as &Active"));
+ activate->setIcon(QIcon::fromTheme("emblem-favorite"));
+ activate->setStatusTip(i18n("Set this output as the file to append output to."));
actionCollection ()->addAction (KStandardAction::Find, "find", window->findbar, SLOT (activate()));
QAction* findAhead = actionCollection ()->addAction ("find_ahead", new QAction (i18n ("Find as you type"), this));
@@ -917,6 +927,7 @@ void RKHTMLWindowPart::setOutputDirectoryActionsEnabled(bool enable) {
window->file_save_action->setVisible(enable);
window->file_save_as_action->setVisible(enable);
revert->setVisible(enable);
+ activate->setVisible(enable);
}
void RKHTMLWindowPart::setOutputWindowSkin() {
@@ -1343,18 +1354,23 @@ void RKOutputWindowManager::setCurrentOutputPath (const QString &_path) {
#endif
if (path == current_default_path) return;
- if (!windows.contains (path)) {
- RK_DEBUG (APP, DL_DEBUG, "starting to watch %s for changes, KDirWatch method %d", qPrintable (path), file_watcher->internalMethod ());
- file_watcher->addFile (path);
+ auto old_win = windows.value(current_default_path);
+ auto new_win = windows.value(path);
+
+ if (!new_win) {
+ RK_DEBUG(APP, DL_DEBUG, "starting to watch %s for changes, KDirWatch method %d", qPrintable(path), file_watcher->internalMethod());
+ file_watcher->addFile(path);
}
- if (!windows.contains (current_default_path)) {
- if (!current_default_path.isEmpty ()) {
- RK_DEBUG (APP, DL_DEBUG, "no longer watching %s for changes", qPrintable (current_default_path));
- file_watcher->removeFile (current_default_path);
+ if (!old_win) {
+ if (!current_default_path.isEmpty()) {
+ RK_DEBUG(APP, DL_DEBUG, "no longer watching %s for changes", qPrintable(current_default_path));
+ file_watcher->removeFile(current_default_path);
}
}
current_default_path = path;
+ if (old_win) old_win->updateState();
+ if (new_win) new_win->updateState();
}
void RKOutputWindowManager::rewatchOutput () {
diff --git a/rkward/windows/rkhtmlwindow.h b/rkward/windows/rkhtmlwindow.h
index ee78489e..615d1bc3 100644
--- a/rkward/windows/rkhtmlwindow.h
+++ b/rkward/windows/rkhtmlwindow.h
@@ -88,6 +88,7 @@ public slots:
void slotSave();
void slotSaveAs();
void slotRevert();
+ void slotActivate();
void slotForward ();
void slotBack ();
void selectionChanged ();
@@ -171,6 +172,7 @@ friend class RKHTMLWindow;
QAction* forward;
QAction* export_page;
QAction* revert;
+ QAction* activate;
};
/**
diff --git a/rkward/windows/rkoutputwindow.rc b/rkward/windows/rkoutputwindow.rc
index 427f2970..298c77e0 100644
--- a/rkward/windows/rkoutputwindow.rc
+++ b/rkward/windows/rkoutputwindow.rc
@@ -18,6 +18,7 @@
<Separator/>
<Action name="output_flush"/>
<Action name="output_revert"/>
+ <Action name="output_activate"/>
</Menu>
<Menu name="view"><text>&View</text>
<Action name="zoom_in"/>
@@ -28,8 +29,8 @@
</Menu>
</MenuBar>
<ToolBar fullWidth="true" name="mainToolBar">
- <Action name="output_flush"/>
<Action name="output_revert"/>
<Action name="output_refresh"/>
+ <Action name="output_activate"/>
</ToolBar>
</kpartgui>
More information about the rkward-tracker
mailing list