[pim/korganizer] /: Add a new "date picker" feature

Allen Winter null at kde.org
Wed Mar 19 12:05:12 GMT 2025


Git commit 447100ea53063192afd424ddf1777d4f4549b455 by Allen Winter.
Committed on 19/03/2025 at 12:01.
Pushed by winterz into branch 'master'.

Add a new "date picker" feature

Allows fast navigating to selected dates using the KDatePicker

BUG: 151660

M  +7    -0    doc/index.docbook
M  +9    -0    src/actionmanager.cpp
M  +10   -0    src/calendarview.cpp
M  +6    -0    src/calendarview.h
M  +3    -1    src/data/korganizer_part.rc
M  +37   -26   src/data/korganizerui.rc
M  +6    -3    src/datenavigator.cpp
M  +1    -0    src/datenavigator.h

https://invent.kde.org/pim/korganizer/-/commit/447100ea53063192afd424ddf1777d4f4549b455

diff --git a/doc/index.docbook b/doc/index.docbook
index e6968a88a..3ab9eace8 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -3348,6 +3348,13 @@ format="PNG"/></imageobject></inlinemediaobject><menuchoice>
 writing a new journal entry</action>.</para></listitem>
 </varlistentry>
 
+<varlistentry id="menu-actions-pick-date">
+<term><inlinemediaobject><imageobject><imagedata fileref="go-jump.png" format="PNG"/></imageobject></inlinemediaobject>
+<menuchoice><guimenu>Go</guimenu><guimenuitem>Pick a Date</guimenuitem></menuchoice>
+</term>
+<listitem><para><action>Opens a a date selection dialog for quickly navigating the view.</action></para></listitem>
+</varlistentry>
+
 <varlistentry id="menu-actions-show-event">
 <term><menuchoice>
 <guimenu>Actions</guimenu>
diff --git a/src/actionmanager.cpp b/src/actionmanager.cpp
index 1f9852bea..9d0b046c7 100644
--- a/src/actionmanager.cpp
+++ b/src/actionmanager.cpp
@@ -601,6 +601,15 @@ void ActionManager::initActions()
     mACollection->addAction(QStringLiteral("new_journal"), mNewJournalAction);
     connect(mNewJournalAction, &QAction::triggered, this, &ActionManager::slotNewJournal);
 
+    /** Scroll to Date Action **/
+    action = new QAction(QIcon::fromTheme(QStringLiteral("go-jump")), i18nc("@action Jump to date", "&Pick a Date"), this);
+    action->setIconText(i18n("Date"));
+    action->setStatusTip(i18nc("@info:status", "Scroll the view to user selected dates"));
+    action->setToolTip(i18nc("@info:tooltip", "Scroll the view to user selected dates"));
+    action->setWhatsThis(i18nc("@info:whatsthis", "Opens a a date selection dialog for quickly navigating the view."));
+    mACollection->addAction(QStringLiteral("pick_date"), action);
+    connect(action, &QAction::triggered, mCalendarView, &CalendarView::goSelectADate);
+
     /** Configure Current View Action **/
     mConfigureViewAction = new QAction(QIcon::fromTheme(QStringLiteral("configure")), i18n("Configure View…"), this);
     mConfigureViewAction->setIconText(i18n("Configure"));
diff --git a/src/calendarview.cpp b/src/calendarview.cpp
index c9fa37ead..ded1900c2 100644
--- a/src/calendarview.cpp
+++ b/src/calendarview.cpp
@@ -68,6 +68,7 @@
 #include <PimCommonAkonadi/CollectionAclPage>
 #include <PimCommonAkonadi/ImapAclAttribute>
 
+#include <KDatePicker>
 #include <KDialogJobUiDelegate>
 #include <KIO/CommandLauncherJob>
 #include <KMessageBox>
@@ -137,6 +138,7 @@ CalendarView::CalendarView(QWidget *parent)
 
     mDateNavigator = new DateNavigator(this);
     mDateChecker = new DateChecker(this);
+    mDatePicker = new KDatePicker(); // must be parent-less
 
     auto topLayout = new QVBoxLayout(this);
     topLayout->setContentsMargins({});
@@ -572,6 +574,14 @@ void CalendarView::goToday()
     mDateNavigator->selectToday();
 }
 
+void CalendarView::goSelectADate()
+{
+    mDatePicker->show();
+    QObject::connect(mDatePicker, &KDatePicker::dateChanged, this, [this](QDate date) {
+        mDateNavigator->selectADate(date);
+    });
+}
+
 void CalendarView::goNext()
 {
     if (qobject_cast<MonthView *>(mViewManager->currentView())) {
diff --git a/src/calendarview.h b/src/calendarview.h
index f0d080efb..fe35ce28f 100644
--- a/src/calendarview.h
+++ b/src/calendarview.h
@@ -55,6 +55,8 @@ class TodoPurger;
 class CalFilterPartStatusProxyModel;
 }
 
+class KDatePicker;
+
 class QSplitter;
 class QStackedWidget;
 
@@ -559,6 +561,9 @@ public Q_SLOTS:
     /** Move the current view date to today */
     void goToday();
 
+    /** Move the current view date to date specified by the user */
+    void goSelectADate();
+
     /** Move to the next date(s) in the current view */
     void goNext();
 
@@ -740,6 +745,7 @@ private:
 
     DateNavigator *mDateNavigator = nullptr;
     DateChecker *mDateChecker = nullptr;
+    KDatePicker *mDatePicker = nullptr;
 
     QWidget *mEventViewerBox = nullptr;
     CalendarSupport::IncidenceViewer *mEventViewer = nullptr;
diff --git a/src/data/korganizer_part.rc b/src/data/korganizer_part.rc
index bbf16d0f5..3d2bf99c2 100644
--- a/src/data/korganizer_part.rc
+++ b/src/data/korganizer_part.rc
@@ -1,5 +1,5 @@
 <!DOCTYPE gui>
-<gui name="korganizer" version="439" translationDomain="korganizer">
+<gui name="korganizer" version="441" translationDomain="korganizer">
   <MenuBar>
     <Menu name="file"><text>&File</text>
       <Merge/>
@@ -81,6 +81,8 @@
       <Action name="new_subtodo"/>
       <Action name="new_journal"/>
       <Separator/>
+      <Action name="pick_date"/>
+      <Separator/>
       <Action name="show_incidence"/>
       <Action name="edit_incidence"/>
       <Action name="delete_incidence"/>
diff --git a/src/data/korganizerui.rc b/src/data/korganizerui.rc
index c99c8091c..9889a88b5 100644
--- a/src/data/korganizerui.rc
+++ b/src/data/korganizerui.rc
@@ -1,15 +1,19 @@
+<?xml version="1.0"?>
 <!DOCTYPE gui>
-<gui name="korganizer" version="437"  translationDomain="korganizer">
+<gui name="korganizer" version="439" translationDomain="korganizer">
   <MenuBar>
-    <Menu name="file"><text>&File</text>
-      <Menu name="import"><text>&Import</text>
+    <Menu name="file">
+      <text>&File</text>
+      <Menu name="import">
+        <text>&Import</text>
         <Action name="import_icalendar"/>
         <Action name="import_ical"/>
         <Merge/>
         <Separator/>
         <Action name="downloadnewstuff"/>
       </Menu>
-      <Menu name="export"><text>&Export</text>
+      <Menu name="export">
+        <text>&Export</text>
         <Action name="export_icalendar"/>
         <Merge/>
         <Separator/>
@@ -20,12 +24,14 @@
       <Action name="purge_completed"/>
       <Separator/>
     </Menu>
-    <Menu name="edit"><text>&Edit</text>
+    <Menu name="edit">
+      <text>&Edit</text>
       <Merge/>
       <Separator/>
       <Action name="edit_delete" append="edit_paste_merge"/>
     </Menu>
-    <Menu name="view"><text>&View</text>
+    <Menu name="view">
+      <text>&View</text>
       <Action name="view_agenda"/>
       <Action name="view_month"/>
       <Action name="view_timeline"/>
@@ -41,7 +47,8 @@
       <Separator/>
       <Action name="filter_select" append="save_merge"/>
       <Separator/>
-      <Menu name="zoom"><text>&Zoom</text>
+      <Menu name="zoom">
+        <text>&Zoom</text>
         <Action name="zoom_in_horizontally"/>
         <Action name="zoom_out_horizontally"/>
         <Separator/>
@@ -49,7 +56,8 @@
         <Action name="zoom_out_vertically"/>
       </Menu>
     </Menu>
-    <Menu name="go"><text>&Go</text>
+    <Menu name="go">
+      <text>&Go</text>
       <Action name="go_previous"/>
       <Action name="go_next"/>
       <Separator/>
@@ -62,12 +70,15 @@
       <Action name="select_newmonth"/>
       <Merge/>
     </Menu>
-    <Menu name="actions"><text>&Actions</text>
+    <Menu name="actions">
+      <text>&Actions</text>
       <Action name="new_event"/>
       <Action name="new_todo"/>
       <Action name="new_subtodo"/>
       <Action name="new_journal"/>
       <Separator/>
+      <Action name="pick_date"/>
+      <Separator/>
       <Action name="show_incidence"/>
       <Action name="edit_incidence"/>
       <Action name="delete_incidence"/>
@@ -78,7 +89,8 @@
       <Separator/>
       <Action name="activate_alarm"/>
     </Menu>
-    <Menu name="schedule"><text>S&chedule</text>
+    <Menu name="schedule">
+      <text>S&chedule</text>
       <Action name="schedule_publish"/>
       <Action name="schedule_request"/>
       <Action name="schedule_reply"/>
@@ -90,9 +102,11 @@
       <Action name="mail_freebusy"/>
       <Action name="upload_freebusy"/>
     </Menu>
-    <Menu name="settings"><text>&Settings</text>
-      <Action name="colorscheme_menu" />
-      <Menu name="sidebar" append="show_merge"><text>&Sidebar</text>
+    <Menu name="settings">
+      <text>&Settings</text>
+      <Action name="colorscheme_menu"/>
+      <Menu name="sidebar" append="show_merge">
+        <text>&Sidebar</text>
         <Action name="show_datenavigator"/>
         <Action name="show_todoview"/>
         <Action name="show_eventviewer"/>
@@ -106,12 +120,13 @@
       <Action name="edit_filters" append="save_merge"/>
       <Action name="edit_categories" append="save_merge"/>
     </Menu>
-    <Menu name="help"><text>&Help</text>
+    <Menu name="help">
+      <text>&Help</text>
       <Action name="show_intro"/>
     </Menu>
   </MenuBar>
-
-  <ToolBar noMerge="1" name="mainToolBar"><text context="main toolbar">Main</text>
+  <ToolBar noMerge="1" name="mainToolBar">
+    <text context="main toolbar">Main</text>
     <Action name="new_event"/>
     <Action name="new_todo"/>
     <Action name="new_journal"/>
@@ -125,8 +140,8 @@
     <Spacer/>
     <Action name="hamburger_menu"/>
   </ToolBar>
-
-  <ToolBar noMerge="1" name="korganizer_toolbar"><text>Views</text>
+  <ToolBar noMerge="1" name="korganizer_toolbar">
+    <text>Views</text>
     <Action name="view_agenda"/>
     <Separator/>
     <Action name="view_month"/>
@@ -135,20 +150,18 @@
     <Action name="view_journal"/>
     <Merge/>
   </ToolBar>
-
-  <ToolBar noMerge="1" name="schedule_toolbar" hidden="true"><text>Schedule</text>
+  <ToolBar noMerge="1" name="schedule_toolbar" hidden="true">
+    <text>Schedule</text>
     <Action name="schedule_publish"/>
     <Action name="schedule_request"/>
     <Action name="schedule_reply"/>
     <Action name="addressbook"/>
   </ToolBar>
-
-  <ToolBar noMerge="1" name="filter_toolbar" hidden="true"><text>Filters Toolbar</text>
+  <ToolBar noMerge="1" name="filter_toolbar" hidden="true">
+    <text>Filters Toolbar</text>
     <Action name="filter_select"/>
     <Action name="edit_filters"/>
-
   </ToolBar>
-
   <Menu name="rmb_selection_popup">
     <Action name="new_event"/>
     <Action name="new_todo"/>
@@ -159,7 +172,6 @@
     <Action name="configure_view"/>
     <Merge/>
   </Menu>
-
   <Menu name="akonadi_collectionview_contextmenu">
     <Action name="akonadi_collection_create"/>
     <Action name="akonadi_collection_delete"/>
@@ -183,5 +195,4 @@
     <Separator/>
     <Action name="serverside_subscription"/>
   </Menu>
-
 </gui>
diff --git a/src/datenavigator.cpp b/src/datenavigator.cpp
index 3def75a66..d14377716 100644
--- a/src/datenavigator.cpp
+++ b/src/datenavigator.cpp
@@ -127,10 +127,8 @@ void DateNavigator::selectWorkWeek(QDate d)
     emitSelected(/* preferredMonth= */ d);
 }
 
-void DateNavigator::selectToday()
+void DateNavigator::selectADate(QDate d)
 {
-    const QDate d = QDate::currentDate();
-
     const int dateCount = mSelectedDates.count();
 
     if (dateCount == 7) {
@@ -142,6 +140,11 @@ void DateNavigator::selectToday()
     }
 }
 
+void DateNavigator::selectToday()
+{
+    selectADate(QDate::currentDate());
+}
+
 void DateNavigator::selectPreviousYear()
 {
     QDate firstSelected = mSelectedDates.first();
diff --git a/src/datenavigator.h b/src/datenavigator.h
index 549fc92b9..252c8cd9b 100644
--- a/src/datenavigator.h
+++ b/src/datenavigator.h
@@ -47,6 +47,7 @@ public Q_SLOTS:
 
     void selectWeekByDay(int weekDay, QDate, QDate preferredMonth = QDate());
 
+    void selectADate(QDate d);
     void selectToday();
 
     void selectPreviousYear();


More information about the kde-doc-english mailing list