1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-07-02 18:32:20 +03:00
Commit Graph

778 Commits

Author SHA1 Message Date
Maarten ter Huurne
60aaf5954a Show a file selector in OPK links only if Exec requires a file
Previously, if a user installed a new version of an OPK with the same
name as one that had a link configuration file, GMenu2X could request
a file for an application whose new version required no files to
launch.

In practice, this transition would occur only once per OPK application,
when its developer decided to use a custom browser after having used
GMenu2X's file browser. This bug would then show GMenu2X's file browser
to request a file that would not even be passed to the application.

Thanks to Nebuleon for analyzing the problem and the above description.
2014-08-14 02:08:51 +02:00
Maarten ter Huurne
35724170f8 Make FileLister::browse not log a non-existing directory as an error
To avoid unnecessary existence checks, we consider browsing a
non-existing directory to be a normal situation.
2014-08-13 22:59:13 +02:00
Nebuleon Fumika
f85ef14b3e Remove unnecessary file existence check in WallpaperDialog::exec()
Browsing the user's wallpaper directory will simply add no new files
to the list of wallpapers available if the directory doesn't exist.
WallpaperDialog::exec doesn't need to care about that.

Because wallpapers are files, not directories, also don't return
directories in the result. The code that makes the wallpapers list
calls FileLister::getFiles and ignores directories anyway.
2014-08-13 22:51:56 +02:00
Nebuleon Fumika
cf896e6175 Remove unnecessary file existence check in GMenu2X::showSettings()
Browsing the user's translations directory will simply add no new files
to the list of translations available if the directory doesn't exist.
GMenu2X::showSettings() doesn't need to care about that.

Because translations are files, not directories, also don't return
directories in the result. The code that makes the translations list
calls FileLister::getFiles and ignores directories anyway.
2014-08-13 22:50:16 +02:00
Nebuleon Fumika
a60a529de6 Remove unnecessary file existence check in GMenu2X::writeSkinConfig
mkdir is able to return an error code in errno to indicate that the
directory requested to be created already exists (EEXIST).
2014-08-13 22:44:43 +02:00
Nebuleon Fumika
8cd3ab8cb8 Remove unnecessary file existence check in GMenu2X::readTmp()
A file existence check is already performed, atomically with respect to
the filesystem, by ifstream's constructor. The result of this check is
available using ifstream::is_open().
2014-08-13 22:43:41 +02:00
Nebuleon Fumika
82ac7ef44b Set the clock to 0 before reading application link files
0 is the default clock value, which doesn't get written to link files
if it's not changed. The clock was previously uninitialised before
reading link files, so it would get written with a random value if
there was none before.
2014-08-13 07:39:37 +02:00
Maarten ter Huurne
13f574bfb2 Avoid moving around entries unless new ones were found
When scanning multiple directories in succession, it's possible that
in some of them no matches are found. Avoid moving all pre-existing
entries back and forth in that case.

Also use move instead of copy for transferring the pre-existing
entries from the vector to the set.
2014-08-13 07:35:29 +02:00
Maarten ter Huurne
90a5f82b92 In FileLister::browse, declare variables when they are needed 2014-08-13 07:14:30 +02:00
Maarten ter Huurne
2c76ddae50 Removed special case handling for !(showDirectories || showFiles)
The special case is not necessary for correctness. It would help
performance in theory, but it seems very unlikely that any code would
request a directory scan when it interested in neither the subdirs nor
the files in that directory.
2014-08-13 07:08:04 +02:00
Maarten ter Huurne
46c64ea984 Move instead of copy strings at the end of FileLister::browse
This takes a little trickery, which I wrapped and documented.
2014-08-13 07:06:07 +02:00
Nebuleon Fumika
f1e92425ac Optimise duplicate checking and sorting in FileLister::browse
Using a std::set makes both duplicate checking and sorting run in
O(n log n).
2014-08-13 07:06:07 +02:00
Nebuleon Fumika
bd7eac32ba Pre-process the filter string in FileLister::setFilter
Instead of splitting the filter for every file in FileLister::browse,
the filter is split immediately in FileLister::setFilter, improving
performance.

getFilter is removed because it was unused. This also removes the need
to update the return type to 'const std::vector&' in the method and
rewrite its callers.
2014-08-13 07:06:07 +02:00
Nebuleon Fumika
0b785770dc Use a plain FileLister instead of a pointer in BrowseDialog
Configuration of the FileLister is now left to the subclasses of
BrowseDialog, as the construction of a FileLister and its configuration
(to show or hide directories and files) have been separated.

This allows deleting the destructors of BrowseDialog's subclasses,
which existed solely to delete a FileLister object constructed by
each subclass.

The allocation of a BrowseDialog now also implies allocating enough
space for its FileLister, so remove the check for fl being nullptr in
BrowseDialog::exec().
2014-08-13 07:06:05 +02:00
Nebuleon Fumika
1dec6f6f11 Split creation, configuration and use of FileLister objects
The constructor now has zero arguments. showDirectories and showFiles
are now set using setter methods.

FileLister::browse is now the sole way to start a scan for files and
directories, replacing the initial path in the constructor and the
setPath method. It allows merging results from multiple directories
as before.

This is all to make explicit how many times the costly task of browsing
a directory is actually carried out.
2014-08-13 04:50:22 +02:00
Nebuleon Fumika
1508ac87ac When editing colors, show the selected color component using its color
Instead of showing 'R:', 'G:', 'B:' and 'A:', which take up a lot of space
and can overlap in standard fonts, the selection rectangle surrounding the
number is red, green, blue or gray, and the text is shorter.

This will allow the labels for the skin colors to be longer for translations
as well, given that their values are shown less wide.
2014-08-13 03:53:22 +02:00
Nebuleon Fumika
ab27096f10 Remove unnecessary file existence check in GMenu2X -> InputManager
Instead of checking which input configuration file exists among 2
choices, then asking InputManager to load that file, InputManager
itself now performs the resolution based on whether ifstream::is_open
returns true for each choice.
2014-08-13 03:29:42 +02:00
Nebuleon Fumika
d6b2643610 Remove unnecessary file existence check in GMenu2X::setSkin(2)
The existence of modifications to the skin configuration in the home
directory is now checked with ifstream::is_open, and the system's skin
configuration is used if that returns false.
2014-08-13 03:26:26 +02:00
Nebuleon Fumika
ebb34f3e00 Remove unnecessary file existence check in main
mkdir is able to return an error code in errno to indicate that the
directory requested to be created already exists (EEXIST).
2014-08-13 03:16:38 +02:00
Nebuleon Fumika
457fb0a085 Remove unnecessary file existence check in GMenu2X::readConfig(string)
A file existence check is already performed, atomically with respect to
the filesystem, by ifstream's constructor. The result of this check is
available using ifstream::is_open().
2014-08-13 03:15:38 +02:00
Maarten ter Huurne
a741653a13 Don't pre-strip file name extensions in Selector
This operation is not so slow that it really needs caching. Also
reducing the delay before showing a directory will have more impact
on the user experience than a slightly faster paint.
2014-08-12 09:17:38 +02:00
Maarten ter Huurne
1e50dff746 Moved code to remove a file name extension into utilities module 2014-08-12 09:07:37 +02:00
Maarten ter Huurne
aa5d8faeb6 Removed SurfaceCollection::defaultAlpha
The Selector was the only user and that code was removed.
2014-08-12 08:50:52 +02:00
Maarten ter Huurne
1229ef32e5 Removed screenshot caching from Selector
The way the caching was implemented was rather problematic. Also I'm
not convinced caching is useful at all. So I removed it. If at some
point we decide that caching is a good idea, it would be best to
re-implement it from scratch, so nothing of value is lost by removing
the existing caching code.

One problem was that the prepare method would check the existence of
a screenshot file for every file in the directory, which adds to the
noticable delay before showing a directory which holds many files.

Another problem is there was no upper limit to the number of
screenshots that would be cached. On directories with many screenshots
the memory use could rise to several hundred megabytes, which can be
problematic on some of the systems we want to support.

Also there was a rather nasty hack present to ensure screenshots were
loaded without an alpha channel.

My main doubt about the usefulness of screenshot caching is that
caching will only speed up the showing of an image from the second
time onwards. In typical use, the average screenshot is displayed at
most once. If the image load time is long enough to annoy the user,
any real solution would have to work also for the first showing.
For example, background (asynchronous) loading could be implemented.
2014-08-12 08:50:04 +02:00
Maarten ter Huurne
3305cf289b Minor cleanups in Selector::exec
Declare variables where they are needed instead of way in advance.
2014-08-12 08:38:05 +02:00
Maarten ter Huurne
b15175b05b Require valid section index passed to Menu::addActionLink
All calls to this method are in GMenu2X::initMenu() and they will only
pass valid indices, so the range check was redundant. Also the return
value was never used.

Added an assert to spot any invalid indices from future code.
2014-08-12 06:42:58 +02:00
Maarten ter Huurne
cc38c8ec00 Fixed misleading indentation in Menu::addActionLink
A reader might have concluded that the icon was always set.
2014-08-12 06:30:56 +02:00
Maarten ter Huurne
6492ab2fa2 Apply a minimum size for the scroll bar thumb
On long lists the computed size can become less than 1 pixel.
2014-08-12 00:01:40 +02:00
Maarten ter Huurne
60183e539d Removed most uses of naked Surface pointers
However, SurfaceCollection remains a very important user.
2014-08-10 14:21:14 +02:00
Maarten ter Huurne
4bd1c799bd Created separate subclasses for output and off-screen surfaces
There are a few exclusive operations for each type. Also we no longer
need the freeWhenDone flag since the class now determines whether the
surface should be freed or not.
2014-08-10 13:25:54 +02:00
Nebuleon Fumika
b3719d1331 Correct the viewport area in TextManualDialog
Hardcoded coordinates now follow gmenu2x's usual content area rules.

Copy-pasted from TextDialog.
2014-08-10 10:24:23 +02:00
Maarten ter Huurne
b833f59bb5 Show at least one row per page
In theory a font could be so large that no full row would fit on the
allotted space; in that case showing a partial row is better than
nothing and will avoid bugs where -1 wraps around on unsigned exprs.
2014-08-10 10:22:13 +02:00
Maarten ter Huurne
0535f8273b Rewrote the manual paging code
Nebuleon spotted a bug in TextManualDialog where the unsigned value
'pages[page].text.size() - rowsPerPage' could wrap around at 0 for
short chapters. I decided to change a bit more than just fixing the
bug though.
2014-08-10 10:09:42 +02:00
Maarten ter Huurne
799ebb9a29 Let SurfaceCollection::add make a copy of an existing surface
This allows the SurfaceCollection to claim ownership of the surface,
while ownership was undefined before.
2014-08-10 05:42:41 +02:00
Maarten ter Huurne
aff5f53f7d Don't pass around naked Surface pointers when drawing
Use references instead.
2014-08-10 04:26:59 +02:00
Maarten ter Huurne
20c5ec4eb6 Put Surface argument first in Dialog paint methods
This is the convention that most classes stick to. The likely reason
why Dialog didn't stick to the convention was to be able to provide
a default value for this argument, but that feature wasn't very useful
since every caller already had access to the default surface.
2014-08-10 04:02:10 +02:00
Maarten ter Huurne
5a281cf661 Implement the standard set of copy and move operations for Surface 2014-08-10 03:18:32 +02:00
Maarten ter Huurne
614f74a63d Removed halfW/H caching in Surface
This is a very cheap computation, no need to cache it.
2014-08-10 02:55:52 +02:00
Maarten ter Huurne
7c4fa5d77a Launch application after destructing menu
This allows all destructors to do their job before we pass control to
a new process.
2014-08-10 02:09:34 +02:00
Maarten ter Huurne
303ecf298a Moved console bind+activate code into Launcher
This way, we can launch console applications from the Explorer.
2014-08-08 02:04:05 +02:00
Maarten ter Huurne
dc23718f7f Enable "Display Console" flag for all platforms
Applications with this flag will not have their stdout/stderr
redirected to a log file when logging is enabled. That is a useful
feature also on platforms where we don't micromanage the console.
2014-08-08 01:35:51 +02:00
Maarten ter Huurne
3e34124e68 Added Launcher class
Currently the launched application is exec-ed from deep within the menu
code. This means a lot of destructors are never run and as a result
for example file descriptors from the menu remain open in the launched
process.

This is a first step to move the launch invocation from a deep call
stack to the top level.
2014-08-07 16:48:30 +02:00
Maarten ter Huurne
e32964bb50 Made Font ownership explicit using unique_ptr 2014-07-31 23:20:31 +02:00
Maarten ter Huurne
902145b698 Removed Surface::write method
All it did was redirect to Font::write, so it's better to call that
method directly.
2014-07-31 23:16:51 +02:00
Maarten ter Huurne
3a57912dca Removed ChangeLog again
Setting the Automake strictness to 'foreign' disables enforcement
of GNU project rules. Thanks to Paul Wise for the tip.
2014-07-25 06:34:34 +02:00
Maarten ter Huurne
98413bac90 Make a pro-forma ChangeLog file
Automake considers an absent ChangeLog to be fatal.
2014-07-24 20:36:44 +02:00
Maarten ter Huurne
5af64ef29f Update translation credit for Norwegian 2014-07-24 14:15:40 +02:00
Maarten ter Huurne
8722b355ac Use a single "about.txt" for all platforms
The content of this file is not actually platform specific, so having
it in multiple locations is just an extra maintenance burden.
2014-07-24 14:13:55 +02:00
Maarten ter Huurne
48dcfc95c5 Removed ChangeLog
It is not maintained. Please read the Git log instead.
2014-07-24 14:09:35 +02:00
KouenHasuki
c1b988980e Update Norwegian
Complete rewrite of the Norwegian GMenu2X for GCW0.

Done by: Lithium Flower
2014-07-24 12:44:12 +02:00